mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-01-31 09:06:17 +00:00
fixes #6203, Model::invalidFields respecting Model::whitelist
git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@8113 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
parent
7f853532d9
commit
de5907326e
2 changed files with 28 additions and 15 deletions
|
@ -2343,9 +2343,15 @@ class Model extends Overloadable {
|
|||
$this->exists();
|
||||
|
||||
$_validate = $this->validate;
|
||||
if (array_key_exists('fieldList', $options) && is_array($options['fieldList']) && !empty($options['fieldList'])) {
|
||||
$whitelist = $this->whitelist;
|
||||
|
||||
if (array_key_exists('fieldList', $options)) {
|
||||
$whitelist = $options['fieldList'];
|
||||
}
|
||||
|
||||
if (!empty($whitelist)) {
|
||||
$validate = array();
|
||||
foreach ($options['fieldList'] as $f) {
|
||||
foreach ((array)$whitelist as $f) {
|
||||
if (!empty($this->validate[$f])) {
|
||||
$validate[$f] = $this->validate[$f];
|
||||
}
|
||||
|
|
|
@ -4983,6 +4983,13 @@ class ModelTest extends CakeTestCase {
|
|||
$TestModel->invalidFields(array('fieldList' => array('name', 'title')));
|
||||
$expected = array('name' => 'This field cannot be left blank', 'title' => 'This field cannot be left blank');
|
||||
$this->assertEqual($TestModel->validationErrors, $expected);
|
||||
$TestModel->validationErrors = array();
|
||||
|
||||
$TestModel->whitelist = array('name');
|
||||
$TestModel->invalidFields();
|
||||
$expected = array('name' => 'This field cannot be left blank');
|
||||
$this->assertEqual($TestModel->validationErrors, $expected);
|
||||
$TestModel->validationErrors = array();
|
||||
|
||||
$this->assertEqual($TestModel->validate, $validate);
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue