1

i am trying to use the symfony form builder to make a form which has 3 fields, name, country and language - i want the form elements to have an id and a name but it creates 2 each time

in the LanguageType

        'id' => 'country_code2',
        'name' => 'country_code'

in twig:

{{ form_widget(form.country_code, {'id': 'country_Code', 'name': 'country_Code'}) }}

is there a way to stop the symfony generated auto id/name

is there any documentation about this 'feature'?

Federkun
  • 36,084
  • 8
  • 78
  • 90
andylondon
  • 176
  • 6
  • Can you post the lines where you create the form? The code you published is kind on confusing. Does this help? http://stackoverflow.com/questions/17070763/how-to-set-a-css-id-attribute-to-a-symfony2-form-input – ggioffreda May 29 '15 at 10:30
  • i the end i decided to stick with the id and name that symfony is sticking in for me. why fight the power!! – andylondon May 29 '15 at 12:43
  • please post your full type. Also, to override in twig: {{ form_widget(form.country_code, {'attr' : {'id': 'country_Code', 'name': 'country_Code'}}) }} Apart from that, have a look at https://github.com/symfony/symfony/blob/2.1/src/Symfony/Bridge/Twig/Resources/views/Form/form_div_layout.html.twig – DerStoffel May 29 '15 at 14:05
  • To override the id you need to move it outside the `attr` property, like so: `{{ form_widget(form.country_code, {'id': 'country_Code', 'attr' : { ... }}) }}` – ggioffreda May 31 '15 at 00:39

0 Answers0