Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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

like image 504
Ess Avatar asked Apr 12 '11 12:04

Ess


People also ask

How to set validation rules in CodeIgniter?

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();

What is Set_value in CodeIgniter?

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.

How to set error message in CodeIgniter?

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.


1 Answers

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

like image 159
AlunR Avatar answered Oct 15 '22 03:10

AlunR