As per the Yii2 docs validation rules can be applied either to the implicit properties (table fields) or to the userDefined properties.
Is there a way to create validation rules for the properties which are dynamically added to the model class ?
For example:
Let there be model class named 'Filter' and another model class named 'Category' - categories like laptop, palmtop, desktop etc. I may want to use trackpad area as one of the filter to the laptop category and diagonal length as one of the filter to palmtop category and so on. So in every case filter conditions vary according to the category I choose and I may want to add it to the model class Filter dynamically and a validation if the load via post was successful.
Aucun commentaire:
Enregistrer un commentaire