diff options
author | JonoB <jon@accountsportal.com> | 2012-03-05 10:51:27 +0100 |
---|---|---|
committer | JonoB <jon@accountsportal.com> | 2012-03-05 10:51:27 +0100 |
commit | 8af2fdfda32303b8e2766d1fc873d1111baeb57e (patch) | |
tree | 69272a940d5e22e193d69f304c01f3028f6afa3e | |
parent | 2baae203864cecd6f7c92b244c28dd18e0051d2c (diff) |
Removed reset_validation() method from run() method
-rw-r--r-- | system/libraries/Form_validation.php | 9 | ||||
-rw-r--r-- | user_guide_src/source/changelog.rst | 1 | ||||
-rw-r--r-- | user_guide_src/source/libraries/form_validation.rst | 11 |
3 files changed, 17 insertions, 4 deletions
diff --git a/system/libraries/Form_validation.php b/system/libraries/Form_validation.php index eb6031697..cdb3d3d62 100644 --- a/system/libraries/Form_validation.php +++ b/system/libraries/Form_validation.php @@ -165,6 +165,10 @@ class CI_Form_validation { * * If an array is set through this method, then this array will * be used instead of the $_POST array + * + * Note that if you are validating multiple arrays, then the + * reset_validation() function should be called after validating + * each array due to the limitations of CI's singleton * * @param array $data * @return void @@ -324,9 +328,6 @@ class CI_Form_validation { return FALSE; } - // Clear any previous validation data - $this->_reset_validation(); - // Does the _field_data array containing the validation rules exist? // If not, we look to see if they were assigned via a config file if (count($this->_field_data) === 0) @@ -1352,7 +1353,7 @@ class CI_Form_validation { * * @return void */ - protected function _reset_validation() + public function reset_validation() { $this->_field_data = array(); $this->_config_rules = array(); diff --git a/user_guide_src/source/changelog.rst b/user_guide_src/source/changelog.rst index e96076164..21675bd16 100644 --- a/user_guide_src/source/changelog.rst +++ b/user_guide_src/source/changelog.rst @@ -84,6 +84,7 @@ Release Date: Not Released - Added $config['csrf_regeneration'] to the CSRF protection in the :doc:`Security library <libraries/security>`, which makes token regeneration optional. - Added function error_array() to return all error messages as an array in the Form_validation class. - Added function set_data() to Form_validation library, which can be used in place of the default $_POST array. + - Added function reset_validation() to form validation library, which resets internal validation variables in case of multiple validation routines. - Changed the Session library to select only one row when using database sessions. - Core diff --git a/user_guide_src/source/libraries/form_validation.rst b/user_guide_src/source/libraries/form_validation.rst index 0d6a49e79..5aa64d032 100644 --- a/user_guide_src/source/libraries/form_validation.rst +++ b/user_guide_src/source/libraries/form_validation.rst @@ -597,6 +597,9 @@ In this case, you can specify the array to be validated:: Creating validation rules, running the validation and retrieving error messages works the same whether you are validating $_POST data or an array. +**Important Note:** If you want to validate more than one array during a single execution, then you should +call the reset_validation() function before setting up rules and validating the new array. + For more info please see the :ref:`function-reference` section below. -.. _saving-groups: @@ -966,6 +969,14 @@ $this->form_validation->set_data(); Permits you to set an array for validation, instead of using the default $_POST array. +$this->form_validation->reset_validation(); +======================================== + + .. php:method:: reset_validation () + + Permits you to reset the validation when you validate more than one array. + This function should be called before validating each new array. + $this->form_validation->error_array(); ======================================== |