Once again an update of the advanced validation approach

Published on May 11, 2006 and tagged with cakephp  validation

This is hopefully the last post about the advanced validation approach for a long time ;-)

As the previous update this update is only for users using CakePHP with a version number higher than 1.0.1.2708 (you find the version number in VERSION.txt). And that is the update: replace the following snippet in the invalidFields() function in your AppModel:

if ($data == null)
{
    if (isset($this->data))
    {
        $data = $this->data;
    }
    else
    {
        $data = array();
    }
}

with

if (isset($this->data))
{
    $data = array_merge($data, $this->data);
}

The reason for that update is that if you modify data in a possible beforeValidate() function, these changes are ignored by the invalidFields() function without this update.

Bake a comment




(for code please use <code>...</code> [no escaping necessary])

© daniel hofstetter. Licensed under a Creative Commons License