Label is not displaying in Symfony form -


i facing issue display label. following code generate form element.

$builder->add(     'hearaboutus', 'choice', [         'choices' => ['online search'=>'online search',             'email'=> 'email',             'my company' => 'my company',             'colleague or friend'=>'colleague or friend',             'existing client' =>'existing client',             'direct mail' => 'direct mail',             'other'=> 'other',],         'label' => 'how did hear us?',         'required' => true,         'expanded'=> true,         'multiple' => false,     ] ); 

i getting following output.enter image description here "notes" label "how did hear us" label not displaying.

you can try override form theme choice widget.

you can :

1- create file named fields.html.twig in app/resources/views/form/

2- in file have extends default twig layout , override checkbox_widget adding <label> tag :

{% extends 'form_div_layout.html.twig' %}  {% block checkbox_widget %} {% spaceless %}     <label>       <input type="checkbox" {{ block('widget_attributes') }}{% if value defined %} value="{{ value }}"{% endif %}{% if checked %} checked="checked"{% endif %} />     </label> {% endspaceless %} {% endblock checkbox_widget %} 

3- finally, tell symfony use in view :

{% form_theme form 'form/fields.html.twig' %} 

Comments

Popular posts from this blog

amazon web services - S3 Pre-signed POST validate file type? -

c# - Check Keyboard Input Winforms -