Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow $options['fieldList'] to be mangled/modified inside beforeValidate(). #957

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions lib/Cake/Model/ModelValidator.php
Expand Up @@ -247,7 +247,7 @@ public function validateMany(&$data, $options = array()) {
* @see ModelValidator::validates()
*/
public function errors($options = array()) {
if (!$this->_triggerBeforeValidate($options)) {
if (!$this->_triggerBeforeValidate(&$options)) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

from: http://php.net/manual/en/language.references.pass.php

There is no reference sign on a function call - only on function definitions.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks ceeram! you are right.

return false;
}
$model = $this->getModel();
Expand Down Expand Up @@ -464,7 +464,7 @@ protected function _validateWithModels($options) {
*/
protected function _triggerBeforeValidate($options = array()) {
$model = $this->getModel();
$event = new CakeEvent('Model.beforeValidate', $model, array($options));
$event = new CakeEvent('Model.beforeValidate', $model, array(&$options));
list($event->break, $event->breakOn) = array(true, false);
$model->getEventManager()->dispatch($event);
if ($event->isStopped()) {
Expand Down