I am trying to use Yii2\'s conditional validator as given in the guide like:
Model code
public function rules() { // $discharged = function($model) {
['package_id_fk', 'required', 'when' => function($model) {return $model->type == 'PACKAGE';}, 'enableClientValidation' => false],
It works for me.