diff options
-rw-r--r-- | system/libraries/Form_validation.php | 2 | ||||
-rw-r--r-- | tests/codeigniter/libraries/Form_validation_test.php | 14 |
2 files changed, 16 insertions, 0 deletions
diff --git a/system/libraries/Form_validation.php b/system/libraries/Form_validation.php index c1cfcdb8f..0dfb274b2 100644 --- a/system/libraries/Form_validation.php +++ b/system/libraries/Form_validation.php @@ -591,6 +591,8 @@ class CI_Form_validation { } else { + $data_ref =& $data; + // before we assign values, make a reference to the right POST key if (count($row['keys']) === 1) { diff --git a/tests/codeigniter/libraries/Form_validation_test.php b/tests/codeigniter/libraries/Form_validation_test.php index ebb14983e..b70f950a2 100644 --- a/tests/codeigniter/libraries/Form_validation_test.php +++ b/tests/codeigniter/libraries/Form_validation_test.php @@ -482,6 +482,20 @@ class Form_validation_test extends CI_TestCase { $this->assertEquals('bar2', $this->form_validation->set_value('bar[]', $default)); } + public function test_issue_5202() + { + $data = array('person' => array('firstname' => 'Dick', 'lastname' => 'Tracy ')); + $this->form_validation->reset_validation(); + $this->form_validation->set_rules('person[firstname]', 'First Name', 'required|trim'); + $this->form_validation->set_rules('person[lastname]', 'Last Name', 'required|trim'); + $this->form_validation->set_data($data); + $valid = $this->form_validation->run('', $data); + + $this->assertEquals(TRUE, $valid); + $this->assertEquals('Dick', $data['person']['firstname']); + $this->assertEquals('Tracy', $data['person']['lastname']); + } + public function test_set_select() { // Test 1: No options selected |