[eluser]jrtashjian[/eluser]
Here is an example, you need to create a form which is used to gather the users address. Fields will include:
- First Name
- Last Name
- Address Line 1
- Address Line 2
- City
- State/Province
- Zip/Postal Code
- Country
I would require all fields except 'Address Line 2' to be filled in. I would set a rule for each field:
Code:
$this->form_validation->set_rules('first_name', 'First Name', 'required');
$this->form_validation->set_rules('last_name', 'Last Name', 'required');
$this->form_validation->set_rules('address_line_one', 'Address Line 1', 'required');
$this->form_validation->set_rules('city', 'City', 'required');
// etc...
Then for each form element on the view I would place set_value('first_name'), set_value('last_name'), etc... for all form elements (including address_line_two).
Upon following the code of the form validation library, only fields that you have declared in set_rules() are ever checked for post values. If it has not been declared, no validation happens, and set_value() will no re-populate.
However, I did notice that this only happens when the form validation library and the form helper is loaded. If only the form helper is loaded, it re-populates the data. I don't believe this is a bug. To me, the form validation library is doing exactly what it's supposed to be doing. I think it has to do with the form helper set_value() method.