Answer the question
In order to leave comments, you need to log in
Yii2. How to cancel a validation rule for a specific element?
You need to cancel validation for specific elements under certain conditions.
I tried this way:
validation rule:
'image' => [
['PhotoFacet', 'PhotoProfile'], 'image', 'when' => function($model) {
return $model->PhotoFacet!="skip";
},'message' => $lang["non_image"], 'notImage' => $lang["non_image"],
],
echo $form->field($model, 'PhotoProfile')->hiddenInput(['value' => 'skip'])->label(false);
echo $form->field($model, 'PhotoFacet')->hiddenInput(['value' => 'skip'])->label(false);
Answer the question
In order to leave comments, you need to log in
$lang["non_image"]
- this array is very confusing, but this is so in the course of the locomotive, it should not affect.
And that's why your validation rules ended up in an array 'image' => [
Show the full code of the model.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question