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 not taken into account in promotion configuration forms #1295

Closed
bburnichon opened this issue Mar 27, 2014 · 6 comments
Closed

Validation not taken into account in promotion configuration forms #1295

bburnichon opened this issue Mar 27, 2014 · 6 comments
Labels
Potential Bug Potential bugs or bugfixes, that needs to be reproduced.

Comments

@bburnichon
Copy link
Contributor

As validation_groups is set to sylius by default, Symfony's Form Component does not validate any of the Constraints set in Forms.

This is a big issue for configuration of promotions which have no underlying object to validate. Only an array.

On a fresh install of Sylius, I just added GreaterThan in ItemCountConfigurationType.

->add('count', 'integer', array(
    'label' => 'sylius.form.rule.item_count_configuration.count',
    'constraints' => array(
        new NotBlank(),
        new Type(array('type' => 'numeric')),
        new GreaterThan(array('value' => 0)),
   )
))

I could saved a -1 value in the item_count_configuration of New Year Promotion

@stloyd stloyd added To Do and removed To Do labels Mar 27, 2014
@pjedrzejewski
Copy link
Member

Reproduced this on local... Still valid unfortunately.

@umpirsky
Copy link
Contributor

@pjedrzejewski I am interested into fixing this issue. Any directions?

@michalmarcinkowski
Copy link
Contributor

@umpirsky According to docs (http://symfony.com/doc/current/book/forms.html#adding-validation), you can just add validation groups to constraint like this:

new NotBlank(array('groups' => array('sylius'))

Tell me if it works :)

@umpirsky
Copy link
Contributor

@michalmarcinkowski This did the trick, thanks!

But, why it does not work with:

class MyConfigurationType extends AbstractType
{
    public function setDefaultOptions(OptionsResolverInterface $resolver)
    {
        $resolver
            ->setDefaults(array(
                'validation_groups' => ['sylius'],
            ))
        ;
    }
}

@michalmarcinkowski
Copy link
Contributor

@umpirsky Not sure what are you asking.

If the form is embedded I suppose it may be connected with cascade validation (http://symfony.com/doc/current/reference/forms/types/form.html#cascade-validation)

Is that your case?

@umpirsky
Copy link
Contributor

@michalmarcinkowski Yes, but that is the case with all rule checker config types. They are embedded by default.

@pjedrzejewski pjedrzejewski added Potential Bug Potential bugs or bugfixes, that needs to be reproduced. and removed Help Wanted Issues needing help and clarification. labels Dec 16, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Potential Bug Potential bugs or bugfixes, that needs to be reproduced.
Projects
None yet
Development

No branches or pull requests

5 participants