Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6835009
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T23:10:52+00:00 2026-05-26T23:10:52+00:00

I am currently developing a Website in which user may buy gift cards. I

  • 0

I am currently developing a Website in which user may buy gift cards. I am using a three step form using the CraueFormFlow bundle and everything is concerning the steps. I am able to validate every simple Assert (like not blank, email, repeated fields, etc) but I am facing the situation where, user may select 0 gift cards and proceed to the next page.

The users may choose the quantity of giftcards they want to buy using two separate : one for 25$ gift cards and one for 50$ gift cards. So I can’t just put a validator saying “value 0 is not allowed”. The validator must prevent a user from leaving the quantity “0” in both amount (25$ and 50$).

Does anyone know how to make a custom validation looking for the values in two fields?

Thanks in advance!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T23:10:53+00:00Added an answer on May 26, 2026 at 11:10 pm

    You have many solutions for this.

    The easiest one is to add a Callback constraint to your model class.

    Another way to do it would be to create your custom constraint and its associated validator. You have a cookbook explaining how to create a custom validation constrain.
    This is the best approach to do it.

    As your constraint does not apply to a property but to a class, you must specify it overriding the the ->getTargets() method of your constraint class:

    class MyConstraint extends Constraint
    {
        // ...
    
        public function getTargets()
        {
            return Constraint::CLASS_CONSTRAINT;
        }
    }
    

    So the value passed as $value argument of the ->isValid() method will contain values of the whole class and not only of a single property.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm currently developing a website which stores bookmarks in a MySQL database using PHP
I'm currently developing a large site that handles user registrations. A social networking website
I'm developing a website which is currently in testing phase. Whenever I make some
I'm currently developing a PM system for a website, in which users must be
I'm currently developing a website which will have heavy load, and a certain amount
I'm currently developing a website which allows the users to upload presentations, documents and
I'm currently developing a mobile website which is heavy on the images, css and
we are currently developing a website which will heavily involve connections to several social
I am currently maintaining and developing a website which uses a lot of webservices
I am currently developing an application which by design has a three-tier architecture. It

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.