For your form, use whenClient:
['name', 'required', 'when' => {serverSide Condition), 'whenClient' => "ut_utils.isAttributeVisible", ], ['name', 'string', 'min' => 2, 'max' => 28], ['name', 'trim'],
And in ut_utils (JS):
isAttributeVisible: function (attribute, value) { return $(attribute.container).is(':visible'); },
You will need to add βwhenβ to test the server side, you can also add specific logic here or use a script to exclude attributes from the check ...
source share