OroCommerce Forums

Covering OroCommerce topics, including community updates and company announcements.

Forums Forums OroCommerce Symfony Form constraints not working for my Custom Form type

This topic contains 3 replies, has 2 voices, and was last updated by  Shahriar 2 years, 3 months ago.

Starting from March 1, 2020 the forum has been switched to the read-only mode. Please head to StackOverflow for support.

  • Creator
  • #40699


    I have created a custom Form Type class

    Then I am adding that in the vendor/oro/commerce/src/Oro/Bundle/ProductBundle/Form/Type/FrontendLineItemType.php class

    Then I added giftcard_price constraint in the vendor/oro/commerce/src/Oro/Bundle/ShoppingListBundle/Resources/config/validation.yml

    The giftcard_price field attribute was already added to the LineItem entity with migration, it has access to that property with getter & setter methods.

    Even after all these,

    While the Form Quantity field has all its required attributes, my custom Form Field is missing the data-validation attribute.

    Can anyone advise, why my Symfony Form Constraints are not working in this case? Thank you.

Viewing 3 replies - 1 through 3 (of 3 total)
  • Author
  • #40708

    Andrey Yatsenko

    When adding constraints to the form you have to define the validation groups, the same way you defined them in a yaml file, otherwise, they will not be applied when the group is chosen during validation.



    But that is already defined in the Parent form type
    vendor/oro/commerce/src/Oro/Bundle/ProductBundle/Form/Type/FrontendLineItemType.php class

    Also the other children Form types like vendor/oro/commerce/src/Oro/Bundle/ProductBundle/Form/Type/QuantityType.php does not have the validation group defined separately.

    Also, more info, my validation works for the Backend which is loaded from the validation.yml. It just does not work on FrontEnd. The input element does not show a ‘data-validation’ attribute for my custom form just like it does for the QuantityType form.

    What am I missing here?

    Thanks in advance.

    • This reply was modified 2 years, 3 months ago by  Shahriar.
    • This reply was modified 2 years, 3 months ago by  Shahriar.


    The Validation works from the Backend, but I want the Frontend Validation as well.

    1. Screen-Shot-2019-10-16-at-3.31.44-PM-128x72
Viewing 3 replies - 1 through 3 (of 3 total)

The forum ‘OroCommerce’ is closed to new topics and replies.

You will be redirected to [title]. Would you like to continue?

Yes No