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

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

/Pelle
Reply
#2

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
Reply
#3

(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 
__construct()
  {
    
parent::__construct();
  }

  public function 
clear_field_data()
  {
    
$this->_field_data = array();
    return;
  }


When you want to clear the form validation data, just invoke the method, like this:
PHP Code:
$this->form_validation->clear_field_data(); 

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.
Reply
#4

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?
Reply
#5

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.
Reply




Theme © iAndrew 2016 - Forum software by © MyBB