diff --git a/lib/Cake/Model/ModelValidator.php b/lib/Cake/Model/ModelValidator.php index 70674938e..508383df8 100644 --- a/lib/Cake/Model/ModelValidator.php +++ b/lib/Cake/Model/ModelValidator.php @@ -251,7 +251,11 @@ class ModelValidator implements ArrayAccess, IteratorAggregate, Countable { $fieldList = $model->whitelist; if (empty($fieldList) && !empty($options['fieldList'])) { - $fieldList = $options['fieldList']; + if (!empty($options['fieldList'][$model->alias]) && is_array($options['fieldList'][$model->alias])) { + $fieldList = $options['fieldList'][$model->alias]; + } else { + $fieldList = $options['fieldList']; + } } $exists = $model->exists(); @@ -380,32 +384,19 @@ class ModelValidator implements ArrayAccess, IteratorAggregate, Countable { } /** - * Processes the Model's whitelist or passed fieldList and returns the list of fields - * to be validated + * Processes the passed fieldList and returns the list of fields to be validated * * @param array $fieldList list of fields to be used for validation * @return array List of validation rules to be applied */ protected function _validationList($fieldList = array()) { - $model = $this->getModel(); - $whitelist = $model->whitelist; - - if (!empty($fieldList)) { - if (!empty($fieldList[$model->alias]) && is_array($fieldList[$model->alias])) { - $whitelist = $fieldList[$model->alias]; - } else { - $whitelist = $fieldList; - } - } - unset($fieldList); - - if (empty($whitelist) || Hash::dimensions($whitelist) > 1) { + if (empty($fieldList) || Hash::dimensions($fieldList) > 1) { return $this->_fields; } $validateList = array(); $this->validationErrors = array(); - foreach ((array)$whitelist as $f) { + foreach ((array)$fieldList as $f) { if (!empty($this->_fields[$f])) { $validateList[$f] = $this->_fields[$f]; }