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'?

4
  • Can you post the lines where you create the form? The code you published is kind on confusing. Does this help? stackoverflow.com/questions/17070763/… Commented May 29, 2015 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!! Commented May 29, 2015 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 github.com/symfony/symfony/blob/2.1/src/Symfony/Bridge/Twig/… Commented May 29, 2015 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' : { ... }}) }} Commented May 31, 2015 at 0:39

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.