[eluser]sqwk[/eluser]
I have a form that is assembled into a variable within the controller, and then passed to the viewfile.
Code:
$searchform .= '<input type="text" name="room_number" value="'.set_value('room_number').'" id="room_number" maxlength="2">';
etc for more elements…
This form submits to the same controller, which checks for $this->input->post and displays the relevant results somewhere further down the page. The form fields are populated again with the previous data with functions like set_value().
So far so good. (It works)
Now I would like to validate some of the input fields…
Code:
$this->load->library('form_validation');
$this->form_validation->set_error_delimiters('<div class="error">', '</div>');
$this->form_validation->set_message('is_natural', 'This is not a number.');
$this->form_validation->set_rules('room_number', 'Anzahl Räume', 'is_natural');
and display the relevant error messages:
Code:
$searchform .= form_error('room_number');
Unfortunately the whole thing falls apart: Form errors are not shown and the form fields are no longer populated with the old entries, not on submitting and not on error (not a natural number) How do I get both to work?