Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
narfbg committed Nov 3, 2012
1 parent d7677ab commit 751f247
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
11 changes: 8 additions & 3 deletions system/libraries/Form_validation.php
Expand Up @@ -440,11 +440,10 @@ public function run($group = '')
// Load the language file containing error messages // Load the language file containing error messages
$this->CI->lang->load('form_validation'); $this->CI->lang->load('form_validation');


// Cycle through the rules for each field, match the // Cycle through the rules for each field and match the corresponding $validation_data item
// corresponding $_POST item and test for errors
foreach ($this->_field_data as $field => $row) foreach ($this->_field_data as $field => $row)
{ {
// Fetch the data from the corresponding $_POST or validation array and cache it in the _field_data array. // Fetch the data from the validation_data array item and cache it in the _field_data array.
// Depending on whether the field name is an array or a string will determine where we get it from. // Depending on whether the field name is an array or a string will determine where we get it from.
if ($row['is_array'] === TRUE) if ($row['is_array'] === TRUE)
{ {
Expand All @@ -454,7 +453,13 @@ public function run($group = '')
{ {
$this->_field_data[$field]['postdata'] = $validation_array[$field]; $this->_field_data[$field]['postdata'] = $validation_array[$field];
} }
}


// Execute validation rules
// Note: A second foreach (for now) is required in order to avoid false-positives
// for rules like 'matches', which correlate to other validation fields.
foreach ($this->_field_data as $field => $row)
{
// Don't try to validate if we have no rules set // Don't try to validate if we have no rules set
if (empty($row['rules'])) if (empty($row['rules']))
{ {
Expand Down
3 changes: 0 additions & 3 deletions user_guide_src/source/libraries/form_validation.rst
Expand Up @@ -910,9 +910,6 @@ Rule Parameter Description
to two parameters, where at least one is required (to pass to two parameters, where at least one is required (to pass
the field data). the field data).


.. note:: When using the **matches** rule, the form item specified
to compare against must already be defined.

****************** ******************
Prepping Reference Prepping Reference
****************** ******************
Expand Down

0 comments on commit 751f247

Please sign in to comment.