Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

validation when not changing status #44

Closed
cornernote opened this issue Feb 15, 2017 · 3 comments
Closed

validation when not changing status #44

cornernote opened this issue Feb 15, 2017 · 3 comments

Comments

@cornernote
Copy link
Contributor

cornernote commented Feb 15, 2017

    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?

@cornernote cornernote changed the title validation validation when not changing status Feb 15, 2017
@raoul2000
Copy link
Owner

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

@cornernote
Copy link
Contributor Author

Can we add another state that checks the current status instead of a transition?

@raoul2000
Copy link
Owner

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 ....

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants