Required Validation

Hello Forum,

I want to apply required validation on condition for textbox.

I have radio button named USERTYPE with value Child and Parent.

if I select Parent from radio button than two textbox will show(implemented by jquery) named Father name and Mother Name.

i need to apply required validation to fatherTextbox and motherTextbox.

#Model

[[‘fatherName’, ‘motherName’], ‘required’, ‘when’ => function($model) {

              return $model->USERTYPE == RelationModel::PARENT;


          }, 


        ],

it is not working.

regards,

webin

Check if everything in the anonymous function returns expected values then check if the textareas added with js are properly named.