Forums

Covering OroCRM topics, including community updates and company announcements.  Subscribe

Forums OroPlatform OroPlatform – Programming Questions Validation form with other conditions

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

  • Creator
    Topic
  • #1657
    thinh2010
    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
  • #1658
    Andrey Yatsenko
    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.

    #1659
    thinh2010
    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)

You must be logged in to reply to this topic.

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

Yes No
ssossossosso