You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Validation of nested attributes can't work due to fact, that yii\validators\Validator uses $model->$attribute instead of $model->getAttribute($attribute) in validateAttribute($model, $attribute) method:
How to overcome this issue? We could override the validateAttribute() method of yii\validators\Validator class in our own inhered class and create a Standalone Validator for every validator type we want to use for nested dynamic attributes.
Is there a better way?
The text was updated successfully, but these errors were encountered:
@TomasMolnar$model->$attribute uses DynamicActiveRecord::__get($name) internally, that also uses $model-> getAttribute($name), so validation is functional (just tested it locally too).
I found that we don't have unit tests for this case, we'll add them. But if validation doesn't work in your case, it must be something else.
Thanks @djagya for your quick response. You are right, the issue was caused by forgotten JsonBehavior, which was tied to the same attribute. I was playing around with the best method of saving schemaless data :)
BTW thanks for this great extension!
If you try to validate nested attributes, it does not work - so even your example is wrong:
Validation of nested attributes can't work due to fact, that yii\validators\Validator uses $model->$attribute instead of $model->getAttribute($attribute) in validateAttribute($model, $attribute) method:
How to overcome this issue? We could override the validateAttribute() method of yii\validators\Validator class in our own inhered class and create a Standalone Validator for every validator type we want to use for nested dynamic attributes.
Is there a better way?
The text was updated successfully, but these errors were encountered: