Note that there are some explanatory texts on larger screens.

plurals
  1. POIndividual field form error message not displaying in Symfony 2.1
    primarykey
    data
    text
    <p>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. </p> <p>However, the <code>{{ form_errors(form.company_name) }}</code> approach to show the error message of that particular field doesn't work for me. It never displays the message. However, if I use <code>{{form_errors(form)}}</code>, all the error messages are displayed in one place. I need the individual <code>{{form_errors(form.company_name)}}</code> way of doing it to work. Did anybody experience this? What could be wrong? Here is my twig code:</p> <pre><code>&lt;form method="post" {{ form_enctype(form) }} novalidate&gt; &lt;table&gt; &lt;tr&gt; &lt;td class="field-cell"&gt;{{ form_label(form.promo_referral) }}:&amp;nbsp;&lt;/td&gt; &lt;td&gt;{{ form_errors(form.promo_referral) }}{{ form_widget(form.promo_referral) }}&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td class="field-cell"&gt;{{ form_label(form.company_name) }}:&amp;nbsp;&lt;/td&gt; &lt;td&gt;{{ form_errors(form.company_name) }}{{ form_widget(form.company_name) }}&lt;/td&gt; &lt;/tr&gt; ... </code></pre> <p>Here is my relevant Controller code:</p> <pre><code>$registration = new ServiceVendorRegistration(); $form = $this-&gt;createForm(new ServiceRegisterForm(), $registration); if ($request-&gt;isMethod("POST")) { $form-&gt;bind($request); if ($form-&gt;isValid()) { // do something else } } return $this-&gt;render('MyBundle:Default:register_service_vendor.html.twig', array('form' =&gt; $form-&gt;createView())); </code></pre> <p>Validation.yml makes the field required as follows:</p> <pre><code>properties: companyName: - NotBlank: message: You have to fill this </code></pre> <p>Any help would be greatly appreciated.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload