I am trying to use Yii2\'s conditional validator as given in the guide like:
Model code
public function rules() { // $discharged = function($model) {
This only worked for me when using the model name (client validation).
['state', 'required', 'when' => function ($model) { return $model->country == 'USA'; }, 'whenClient' => "function (attribute, value) { return $('#MODELNAMEHERE-country').val() == 'USA'; }"]