OroPlatform Forums

Covering OroPlatform topics, including community updates and company announcements.

Forums Forums OroPlatform OroPlatform – Programming Questions Validation form with other conditions

This topic contains 2 replies, has 2 voices, and was last updated by  thinh2010 6 years, 1 month ago.

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

  • Creator
    Topic
  • #34473

    thinh2010
    Participant

    Hi team,

    I would like to make a custom validate. The logic is:
    – If the customer is student (tick option ‘student’), the form will validate also other extra fields, like school, age, … if not, the form will not validate these fields.

    Could you please give me an advice to do that.

    Thanks.

Viewing 2 replies - 1 through 2 (of 2 total)
  • Author
    Replies
  • #34474

    Andrey Yatsenko
    Moderator

    Hi thinkh2010,
    You should not validate the form in 99% cases, validate the entity instead.
    And you can do any custom validation logic with Callback validator at the entity side with annotation or yaml configuration or at the form with “constraints” option https://symfony.com/doc/current/reference/constraints/Callback.html

    Don’t forget to set proper validation groups for the constraint if the entity has several forms or places to use it commonly used.

    #34475

    thinh2010
    Participant

    Hi,

    Thank you for your reply, and sorry for my late response. Currently I am using form validate (in POST_SUBMIT event). I will try your solution :)

Viewing 2 replies - 1 through 2 (of 2 total)

The forum ‘OroPlatform – Programming Questions’ is closed to new topics and replies.

Back to top