Answer the question
In order to leave comments, you need to log in
Why doesn't when in rule work?
Hi friends.
There is a rule in the settings form:
['value', 'integer', 'min' => '1', 'max' => '9', 'when' => function($m) { return $m->param == 'sku_max'; }],
Answer the question
In order to leave comments, you need to log in
It turns out everything worked as it should on the PHP side. and here client validation ignores when, from here and did not start up further. the solution is to turn off client-side validation:
in the form parameters.
the problem is not in the rule, if this rule works for you, then really $m->param == 'sku_max' returns true. Here you need to debug the code, maybe you have param set to 'sku_max' by default, and for example you do not load a new parameter name into the model
Instead of "value" you need to specify the name of your parameter "param", because you check it for equality to the value of 'sku_max'
['param', 'integer', 'min' => '1', 'max' => '9', 'when' => function($m) {
return $m->param == 'sku_max';
}],
['param', 'in', 'range' => range(1, 9)],
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question