YII2 : two models form validation, 2nd model require depend on 1st model input


I am using YII2, advanced template, generate models using gii.

I have created a form with two models (A and B), all validation rules define in respective model except one rule, what is the best practice for the following case.

in form

input fields for model A.

two input fields [size="2"]and one radio button [/size]CATEGORY [size="2"](YES or NO). all require[/size]

input fields for model B.

[size="2"]three input fields are require and [/size]

[size="2"]four extra input fields are depend on CATEGORY radio button, [/size]

[size="2"]If user checked on YES than extra fields are require and if checked on NO than no need for extra fields.[/size]

[size="2"]so how can I define a rule for the above case? in which model?[/size]