Welcome Guest, Not a member yet? Register   Sign In
Form Validation class/repopulating
#1

[eluser]mcair[/eluser]
Noob to CI, need help understand the Form Validation class, specifically when re-populating the form

Controller has logic:
Code:
$this->form_validation->set_rules('shortdesc','League Name','required|trim|min_length[1]|max_length[45]');
    $this->form_validation->set_rules('longdesc','Comments','trim|max_length[255]');

and this appears to work. Having done this, and following the example from the user guide I expect that

Code:
echo 'set_value::shortdesc='.set_value('shortdesc');

will display the submitted value in the shortdesc input field. It doesn't. When I echo the $_POST['shortdesc'] I can see the submitted value. I get the impression from the user guide that set_rules will create and store a member variable on the Form Validation class that corresponds to the input field.

I added the following immediately after the set_rules, it made no difference:

Code:
$fields['shortdesc'] = 'League Name';
    $this->validation->set_fields($fields);


Any guidance you can offer is much appreciated.
#2

[eluser]Ben Edmunds[/eluser]
Call set_value like so

Code:
$this->form_validation->set_value('shortdesc')

and I'm not sure if you have to but I've always called it after

Code:
$this->form_validation->run()
#3

[eluser]mcair[/eluser]
Adding the run() does the trick. Cheers!
#4

[eluser]Ben Edmunds[/eluser]
enjoy!




Theme © iAndrew 2016 - Forum software by © MyBB