I wrote a custom validation rule to which I am trying to pass some parameters.
One of the parameters should be a return value from a function. However the value does not get passed along.
If I call the same function within the custom rule then I can get the return value. It just doesn't work for me to set a parameter using this technique…
Here is the code I am using:
// Within the rules:
array('someAttribute', 'customValidation', 'parameter'=>$this->someFunction(), 'anotherParameter'=>'someValue'),
// The function which should return something...
public function someFunction()
{
if ($this->someOtherAttribute == 1)
return 2;
return 1;
}
// The custom rule:
public function customValidation($attribute, $params)
{
print_r($params);
echo "function " . $this->someFunction();
DIE();
}
/* The above customValidation prints:
*
* array (
* [parameter]=>
* [anotherParameter]=>someValue
* )
*
* function 1
*/

Help
















