raoul2000 / yii2-workflow

A simple workflow engine for Yii2

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Validation on dependant model

ferllings opened this issue · comments

Hi,

Is it possible to use the validation events on a secondary model?

I have my main model A, witch holds the workflow status.
But I also have a secondary B model, with additional fields that require validation on the A workflow events.

commented

Hi,
the validation based on workflow events only applies to the model that holds the statusattribute (the one who triggers the validation when its status changes). That being said, Yii2 allows you to create your own validator and so, assuming you have access to the secondary model from the primary model, you could perform any validation you want in this custom validator (including validating attributes owned by the secondary model).
Again this is outside of the yii2-workflow scope but could be addressed by Yii2 Validation features.

Hope it helps
😎

Thanks, it does help. !