codeigniter form validation set_value works only for the fields which have rules

Ess picture Ess · Apr 12, 2011 · Viewed 11.5k times · Source

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 !!!

Answer

AlunR picture AlunR · Apr 12, 2011

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