Welcome Guest, Not a member yet? Register   Sign In
Unset rule in Form Validation

I need to unset rules and result in Form Validation helper.
How can I do that?


Just set the rules based on what you need instead of unsetting what you dont need. You can do that using if/else and only setting what you need.
- Ben Edmunds
 CI Counsel Member  |  @benedmunds
 Ion Auth  |  Securing PHP Apps

(11-04-2014, 03:09 PM)Isterklister Wrote: I need to unset rules and result in Form Validation helper.

This will clear the entire form validation data, including rules, values, errors, etc.

Create a file called MY_form_validation.php in your application/libraries folder. In that file, put the following code:
PHP Code:
class MY_Form_validation extends CI_Form_validation {

  public function 

  public function 
$this->_field_data = array();

When you want to clear the form validation data, just invoke the method, like this:
PHP Code:

That is useful when you want to process data and then show the same form again -- but blank -- to receive new data, like when you're adding one customer record after another.

Since CI 3.0 I cant' get this to work. Also tried reset_validation() and I still get the same data in the form.

Any one else?

I have the same problem. How can I solve it?

I have a view with the form and a controller with the validation methods. If I submit the form I don't get the form fields empty.

Theme © iAndrew 2016 - Forum software by © MyBB