When using the when clause in rules/validation function in the model, I seem to always get the validation fired. My original code was:
[['avalue'], 'required', 'when' => function ($model) {
return ($model->anull == 'N');
}
],
This seemed to always evaluate to making the avalue
a required filed.
Then I tried these two hard-coded variations. Same results - it’s as if the when
clause does not exist.
[['avalue'], 'required', 'when' => true],
[['avalue'], 'required', 'when' => false],