diff options
author | zoaked <zoaked@users.noreply.github.com> | 2015-09-20 23:16:24 +0200 |
---|---|---|
committer | zoaked <zoaked@users.noreply.github.com> | 2015-09-20 23:16:24 +0200 |
commit | 60858b65a4be78b1d384492588b52e98fd644403 (patch) | |
tree | 093bce00c33c105b85415e16d40bb0e4bc249848 /system | |
parent | 882ab12a32c1c2ccef3e833c319b54eab7ee92ec (diff) |
Persist config file settings when resetting form_validation
When checking multiple arrays using form_validation you have to call reset_validation between each separate check due to the instance of the library being a singleton. The issue comes in when the settings are loaded from a config file as they are initially loaded from a parameter in the constructor, but are set to an empty array when resetting the class. To get around this issue a copy of the config parameter is made and then the copy is used to reset the rules when clearing.
Diffstat (limited to 'system')
-rw-r--r-- | system/libraries/Form_validation.php | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/system/libraries/Form_validation.php b/system/libraries/Form_validation.php index af90316a4..a2991395c 100644 --- a/system/libraries/Form_validation.php +++ b/system/libraries/Form_validation.php @@ -68,6 +68,7 @@ class CI_Form_validation { * @var array */ protected $_config_rules = array(); + private $_default_config_rules = array(); /** * Array of validation errors @@ -141,7 +142,7 @@ class CI_Form_validation { } // Validation rules can be stored in a config file. - $this->_config_rules = $rules; + $this->_default_config_rules = $this->_config_rules = $rules; // Automatically load the form helper $this->CI->load->helper('form'); @@ -1586,7 +1587,7 @@ class CI_Form_validation { public function reset_validation() { $this->_field_data = array(); - $this->_config_rules = array(); + $this->_config_rules = $this->_default_config_rules; $this->_error_array = array(); $this->_error_messages = array(); $this->error_string = ''; |