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

  • Home
  • SEARCH
  • 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 8371717
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T14:13:51+00:00 2026-06-09T14:13:51+00:00

I try to pass my variable to constraint in form validator, but can’t. i’m

  • 0

I try to pass my variable to constraint in form validator, but can’t.
i’m doing that:

$payForm = $this->createForm(new CableTVPayType(), null, array('balance' => $balance));

And in CableTVPayType:

public function getDefaultOptions(array $options)
{
    $maxSumm = $options['balance'] - 100;
    [...]

It works fine, my maxSumm is what i want, but Symfiony checks $options array. ‘balance’ isn’t a default option, and complain about this:

The option "balance" does not exist 

Is there another, more right way to pass custom variable to validation?

  • 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-06-09T14:13:52+00:00Added an answer on June 9, 2026 at 2:13 pm

    Done with this!

    Crate variable for a class, and passing value to it through construct method

    class CableTVPayType extends AbstractType {
    
        private $maxSumm;
    
        public function __construct($maxSumm) {
            $this->maxSumm = $maxSumm;
        }
    

    Create form with argument

    $payForm = $this->createForm(new CableTVPayType($someValue));
    

    Now i can use this variable as i want in my form.

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

Sidebar

Related Questions

I try to pass variable from jquery to code c# but something is wrong.
It works if I use loadMovie(http://graph.facebook.com/100000108805716/picture, imageLoader2); but as I try to pass that
I want to pass more than one variable to other web pages. I try
I'm trying to pass a variable by reference to a different class, but I
I try to pass Package variable to my UserControl: <uc:Template ID=Template runat=server Package=<%=TemplateParams.SimpleSearch %>
Whenever I try to pass a variable through url with the l() function like:
I have to pass a variable through an animation sequence, but I'm having trouble
the problem i am face right now is i can't pass a variable from
Try to debug this script. I think it maybe an issue of variable interpolation?
What is the difference between ',' and 'as' in except statements, eg: try: pass

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.