validation when not changing status
cornernote opened this issue · comments
public function rules()
{
return [
[['status'],raoul2000\workflow\validation\WorkflowValidator::className()],
[['published_date'],'required',
'on' => 'enter status {post/published}'],
];
}
When I change to status=published
I require published_date
.
However once it's in published, there is no validation unless the status changes again.
It would be nice if I could say published_date
was required if status=published
(or if the status is in a given list). Is there any easy way to do this without making a custom validator?
Hi @cornernote,
as you have understood, the WorkflowValidator
validator only perform validation on status change and right now, only a custom validator could do what you describe
Can we add another state that checks the current status instead of a transition?
yes that's an option. Another option could be to create a reflexive transition from {post/published} ot itself. This way, when the model is saved and the status does not change, yii2-workflow will assume it is dealing this transition and perform configured validation.
That could work ....