Hi,
What is the best way to run a validation if the record is a new record. I use to use scenarios in Yii 1 for this because we had the "insert" scenario by default. But Yii 2 does not seem to have this and I have to define the scenarios manually.
I tried doing this …
["upload", "required", "when" => function($model) { return $model->isNewRecord; }],
But it does not work as the isNewRecord property does not appear to be set at the point in time the validation code is run.
Is there a way to do this without using scenarios?