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 3 months, 1 week ago.

The forum will run in the read-only mode starting from March 1. Please head to StackOverflow for support.

  • Creator
    Topic
  • #40699

    Shahriar
    Participant

    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
    Replies
  • #40708
    Andrey Yatsenko
    Andrey Yatsenko
    Moderator

    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.

    #40711

    Shahriar
    Participant

    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 3 months, 1 week ago by  Shahriar.
    • This reply was modified 3 months, 1 week ago by  Shahriar.
    #40715

    Shahriar
    Participant

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

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

You must be logged in to reply to this topic.

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

Yes No