Im using codeigniter validation class when submit forms. Also I
m using set_value() to re-populate fields on form fails. If I have
$this->form_validation->set_rules('name', 'Name', 'required')
set_value() works and fiel开发者_如何学运维d is re-populated. But what if I dont won
t the field to be required ? If I do not add $this->form_validation* re-populating is not working
The website-lab's post is correct - it's a feature of CI that no set_value($foo)
are returned unless there is a validation rule.
If you don't want to have empty validation rules, there are a few hacks available and you can extend the form helper
this thread has a lot of information -
http://codeigniter.com/forums/viewthread/96617/P15/#689642
I also believe you can just use
$this->input->post('my_field')
in your view, if using empty validations or hacking the core doesn't appeal to you.
Include the field form in the validation class but do not set any rules for it.
$this->form_validation->set_rules('someField', '', '');
This field data will now work with set_value
but wont have any validation rules run across it.
精彩评论