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 9226605
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T04:52:16+00:00 2026-06-18T04:52:16+00:00

I have a simple form in Symfony 2.1 and when I submit it, I

  • 0

I have a simple form in Symfony 2.1 and when I submit it, I expect to see some error messages displayed on my form page because I denoted some fields as required.

However, the {{ form_errors(form.company_name) }} approach to show the error message of that particular field doesn’t work for me. It never displays the message. However, if I use {{form_errors(form)}}, all the error messages are displayed in one place. I need the individual {{form_errors(form.company_name)}} way of doing it to work. Did anybody experience this? What could be wrong? Here is my twig code:

<form method="post" {{ form_enctype(form) }} novalidate>
  <table>
  <tr>
    <td class="field-cell">{{ form_label(form.promo_referral) }}:&nbsp;</td>
    <td>{{ form_errors(form.promo_referral) }}{{ form_widget(form.promo_referral) }}</td>
  </tr>
  <tr>
    <td class="field-cell">{{ form_label(form.company_name) }}:&nbsp;</td>
    <td>{{ form_errors(form.company_name) }}{{ form_widget(form.company_name) }}</td>
  </tr>
  ...

Here is my relevant Controller code:

$registration = new ServiceVendorRegistration();
$form = $this->createForm(new ServiceRegisterForm(), $registration);

if ($request->isMethod("POST")) 
{
    $form->bind($request);
    if ($form->isValid())
    {
              // do something else
    }
}

return $this->render('MyBundle:Default:register_service_vendor.html.twig', array('form' => $form->createView()));

Validation.yml makes the field required as follows:

properties:
        companyName:
            - NotBlank:
                message: You have to fill this

Any help would be greatly appreciated.

  • 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-18T04:52:17+00:00Added an answer on June 18, 2026 at 4:52 am

    I got the solution. Symfony doesn’t like it when I name my form fields using underscore to separate words, like first_name. It relies on camelCase naming convention. When I renamed my form fields correspondingly, it started working right.

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

Sidebar

Related Questions

Have a simple form (only extract fields here) but for some reason the JQserilization
I have a simple form on a page and I want to auto submit
I have a pretty simple form with some fields from a doctrine model. $this->widgetSchema['fields']
I have simple form with a textarea and a button, and I submit the
I have a simple form. Its got one field and a submit button. I
I have simple registration form. Once all information entered, user click submit button and
I have simple login form I am using SQLite database which has fields like
Recently I am working on symfony. I have created a simple form and want
I have a symfony form and i need to add a couple of fields(widgets)
I have a simple form with some text inputs and a file input. I

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.