Custom Validation Not Working- Yii2-app-basic-Yii2

前端 未结 5 2311
借酒劲吻你
借酒劲吻你 2021-01-20 09:48

I Posted one question yesterday regarding custom validation for radio button Textfield Mandatory On Radio Button. I got answer. But, that was not exact answer. But, it solve

5条回答
  •  执念已碎
    2021-01-20 09:57

    Atlast, i got my answer

         //company_name
          ['company_name', 'required', 'when' => function($model){
            return ($model->user_type == 'Firm' ? true : false);
          }, 'whenClient' => "function (attribute, value) {
              return $('input[type=\"radio\"][name=\"Users[user_type]\"]:checked').val() == 'Firm';
          }"],
    

提交回复
热议问题