vassy, on 08 February 2010 - 07:48 AM, said:
Hello.
How can I enable/disable form rule using some condition?
Example:
public function rules()
{
return array(
array('email', 'email', 'enable' => app()->param['checkEmail'])
);
}
So rule is validated if app->param['cehckEmail'] is true.
Thank you.
Try this
public function rules()
{
return array(
array(app()->param['checkEmail']?'email':'', 'email')
);
}
Edit:
I accidentally modified the attribute instead of the rule specifier. This is what I first intended to do:
public function noRule($attribute,$params) { }
public function rules()
{
return array(
array('email', app()->param['checkEmail']?'email':'noRule')
);
}
/Tommy
This post has been edited by tri: 08 February 2010 - 09:11 AM