RequiredValidator with typed properties
DplusG opened this issue · comments
Dmitriy Goriaev commented
Q | A |
---|---|
Yii version | 2.0.49 |
PHP version | 7.4 |
Is bugfix | Yes |
Breaks BC? | No (not sure) |
What steps will reproduce the problem?
$model = SomeModelWithTypedProperties();
$model->setAttributes([]);
$model->validate();
What is the expected result?
Validation error, Prop1 cannot be blank.
What do you get instead?
Typed property prop1 must not be accessed before initialization
Solution
Change RequiredValidator. See @DplusG/yii2-required-validator