Suppose if I have two fields in my form viz first_name and last_name
I have set the validation rule only for first_name.
set_value should work for both the fields regardless of rule ? right ?
For me it works only for the fields which have rules with them !!!
CodeIgniter lets you set as many validation rules as you need for a given field, cascading them in order, and it even lets you prep and pre-process the field data at the same time. To set validation rules you will use the set_rules() method: $this->form_validation->set_rules();
The set_value function just sets the value, the only benefit to using it is it simplifies setting the value to an already submitted value when redisplaying the form or showing a default value when the form has yet to be submitted.
In addition, it has an error logging class that permits error and debugging messages to be saved as text files. By default, CodeIgniter displays all PHP errors. You might wish to change this behavior once your development is complete. You'll find the error_reporting() function located at the top of your main index.
set_value only works against the items you have chosen to validate using the form_validation class.
Easiest way is to pretend you are validating by adding this to your form validation config
array(
'field' => 'address1',
'label' => '',
'rules' => ''
),
There is a hack someone has done to the CI library but I haven't been able to find the documentation on that today...Or use this modification instead:
http://codeigniter.com/forums/viewthread/159535/#775628
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With