I'm using YiiConditionalValidator.php extension to Yii 1.1.20. I want to have required field (master_id) when i switch button (is_master) from 1 to 0 ...
is_master - 1 or 0 master_id - if "is_master" = 0 make "master_id required...
So... my model rule looks like this:
public function rules()
{
return [
['is_master', 'required'],
['is_master', 'validators.YiiConditionalValidator',
'if' => [
['is_master', 'compare', 'compareValue'=> "0"],
],
'then' => [
['master_id', 'required'],
],
],
['is_master, master_id', 'safe', 'on' => 'search'],
];
}
And in my form i have this options set:
'enableAjaxValidation' => false,
'enableClientValidation' => true,
'clientOptions' => array(
'validateOnChange' => true,
'validateOnSubmit' => true,
),
It seems like my $form cant see this conditional rule...
Thanks for any Help!