Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Use form validation_group in embedded form #17302

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

Closed
apoberez opened this issue Jan 8, 2016 · 1 comment
Closed

Use form validation_group in embedded form #17302

apoberez opened this issue Jan 8, 2016 · 1 comment

Comments

@apoberez
Copy link

apoberez commented Jan 8, 2016

I have embedded form type with validation group which is important for parent form, but according to this http://symfony.com/doc/current/reference/forms/types/form.html#cascade-validation it's not considered. Is there some way to force it's usage?

CurrencyBundle\Entity\Price:
    constraints:
        - CurrencyBundle\Validator\Constraints\OptionalPrice:
            groups: [Optional]
    properties:
        value:
            - NotBlank:
                groups: [Default]
            - Type:
                groups: [Default, Optional]
                type: numeric
            - Range:
                groups: [Default, Optional]
                min: 0
        currency:
            - NotBlank:
                groups: [Default]
            - Currency:
                groups: [Default, Optional]

RFPBundle\Entity\Request:
    properties:
        requestProducts:
            - Valid: ~

RFPBundle\Entity\RequestProduct:
    properties:
        requestProductItems:
            - Valid: ~

RFPBundle\Entity\RequestProductItem:
    properties:
        price:
            - Valid: ~


class RequestProductItemType extends AbstractType
{
    /**
     * {@inheritdoc}
     */
    public function buildForm(FormBuilderInterface $builder, array $options)
    {
        $builder
            ->add(
                'price',
                PriceType::NAME,
                [
                    'currency_empty_value' => null,
                    'label' => 'rfp.requestproductitem.price.label',
                    'validation_groups' => ['Optional'],
                ]
            );
}
@jakzal
Copy link
Contributor

jakzal commented Jan 8, 2016

If I understood your report correctly this is a duplicate of #3622.

The group is always propagated to the cascaded object with the Valid constraint. See #9650 (comment) and #9650 (comment)

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