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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T13:18:44+00:00 2026-06-11T13:18:44+00:00

OK so i have a choice form with 2 options $builder->add(‘type’, ‘choice’, array( ‘label’

  • 0

OK so i have a choice form with 2 options

$builder->add('type', 'choice', array(
    'label' => 'User type',
    'choices' => array('1' => 'Customer', '2' => 'Supplier'),
    'expanded' => true,
    'multiple' => false,
    'required' => false,
));

And i want to split options in view using twig to get something like this:

{{ form_widget(form.type/choice_1/) }}
some html stuf
{{ form_widget(form.type/choice_2/) }}

Any sugestions?

  • 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-11T13:18:45+00:00Added an answer on June 11, 2026 at 1:18 pm

    You need to add template to the form. Here’s the docs:
    http://symfony.com/doc/current/cookbook/form/form_customization.html

    Here you got multiple examples:
    https://github.com/phiamo/MopaBootstrapBundle/blob/master/Resources/views/Form/fields.html.twig

    This field is for you:

    {% block choice_widget_expanded %}
    {% spaceless %}
    <div {{ block('widget_container_attributes') }}>
    {% for child in form %}
        <label class="{{ (multiple ? 'checkbox' : 'radio') ~ (widget_type ? ' ' ~ widget_type : '') ~ (inline is defined and inline ? ' inline' : '') }}">
            {{ form_widget(child, {'attr': {'class': attr.widget_class|default('')}}) }}
            {{ child.vars.label|trans({}, translation_domain) }}
        </label>
    {% endfor %}
    </div>
    {% endspaceless %}
    {% endblock choice_widget_expanded %}
    

    You can do whatever you want just leave the: {{ form_widget(child, {'attr': {'class': attr.widget_class|default('')}}) }} alone 🙂

    1. You need to create file YourBundle/Resources/Form/fields.html.twig
    2. Paste there the code above.
    3. Add theming to the form: {% form_theme form 'AcmeDemoBundle:Form:fields.html.twig' %}
    4. And be ready to rock’n’roll!
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this field in form builder ->add('pay_method', 'choice', array( 'choices' => array( 'telnet'
I want to have multiple multiple choices given to user after the form submit
I have a form where the user has to enter a list of choices
I have a django form that allows a user to select multiple options: CARDS
So, in a form I have multiple choice and therefore an array of answers
I have an embedded form with a choice widget. I'm trying to pass a
I have a form that has a choice list: <select name=cellSerpro id=idcellserpro class=field text
I need to find a way to have the multiple choice options in a
I have n number of choices in a select box. After the user selects
I have a django choice set which I display in a form : PRIORITIES_CHOICES

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.