Welcome Guest, Not a member yet? Register   Sign In
Form Validation
#8

Flashdata is not intended for repopulating a form that doesn't meet the form validation rules.
A better method is using the form_validation library.

Basically, your method (in the controller) can look look like this:
PHP Code:
public function show_form()
{
  $this->load->library('form_validation');
  $this->form_validation->set_rules('name','name','required');
  if ($this->form_validation->run() == FALSE) {
    $this->load->helper('form');
    //code to load the form view here.
  }
  else {
    //code to process $this->input->post().
    redirect('page_you_want_to_show_after_saving_post_data');
  }

In your view:
PHP Code:
echo form_open();
echo 
form_label('Your name:');
echo 
form_input('name',set_value('name'NULL));
echo 
form_submit('submit','Submit form');
echo 
form_close(); 

form_open() without any parameters will just submit your form to the controller where it came from.
Reply


Messages In This Thread
Form Validation - by ignitedcms - 08-04-2015, 11:11 AM
RE: Form Validation - by mwhitney - 08-04-2015, 01:36 PM
RE: Form Validation - by Diederik - 08-04-2015, 03:02 PM
RE: Form Validation - by ignitedcms - 08-04-2015, 03:40 PM
RE: Form Validation - by Diederik - 08-04-2015, 10:36 PM
RE: Form Validation - by ignitedcms - 08-05-2015, 12:08 AM
RE: Form Validation - by mwhitney - 08-05-2015, 07:26 AM
RE: Form Validation - by Diederik - 08-05-2015, 01:43 AM
RE: Form Validation - by Wouter60 - 08-05-2015, 06:50 AM
RE: Form Validation - by CroNiX - 08-05-2015, 07:20 AM
RE: Form Validation - by ignitedcms - 08-05-2015, 11:55 AM
RE: Form Validation - by mariek - 08-14-2015, 08:40 AM
RE: Form Validation - by mwhitney - 08-14-2015, 09:54 AM
RE: Form Validation - by mariek - 08-17-2015, 12:34 AM



Theme © iAndrew 2016 - Forum software by © MyBB