Welcome Guest, Not a member yet? Register   Sign In
Form validation redirect to same page
#1

[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&auml;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?


Messages In This Thread
Form validation redirect to same page - by El Forum - 12-01-2009, 09:46 PM
Form validation redirect to same page - by El Forum - 12-02-2009, 12:17 AM
Form validation redirect to same page - by El Forum - 12-02-2009, 06:34 AM
Form validation redirect to same page - by El Forum - 12-02-2009, 06:44 AM
Form validation redirect to same page - by El Forum - 12-02-2009, 06:57 AM
Form validation redirect to same page - by El Forum - 12-02-2009, 06:59 AM
Form validation redirect to same page - by El Forum - 12-02-2009, 07:10 AM
Form validation redirect to same page - by El Forum - 12-02-2009, 05:35 PM
Form validation redirect to same page - by El Forum - 12-02-2009, 07:22 PM
Form validation redirect to same page - by El Forum - 12-03-2009, 02:27 AM
Form validation redirect to same page - by El Forum - 12-03-2009, 08:13 AM
Form validation redirect to same page - by El Forum - 12-03-2009, 08:38 AM
Form validation redirect to same page - by El Forum - 12-03-2009, 08:48 AM



Theme © iAndrew 2016 - Forum software by © MyBB