Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

ChoiceType generates options in selectbox with parent's attributes #16534

Copy link
Copy link
Closed
@ossinkine

Description

@ossinkine
Issue body actions

I've created TestFormType

class TestType extends AbstractType
{
    public function buildForm(FormBuilderInterface $builder, array $options)
    {
        $builder->add('choice', 'choice', ['choices' => ['foo', 'bar']]);
    }

    public function getName()
    {
        return 'test';
    }
}

created the form in the controller and passed to the view

class DefaultController extends Controller
{
    public function indexAction(Request $request)
    {
        return $this->render('AppBundle::index.html.php', [
            'form' => $this->createForm('test')->createView(),
        ]);
    }
}

rendered in the view

<?php echo $view['form']->widget($form['choice']) ?>

and I got this:

<select id="test_choice" name="test[choice]">
    <option value="0" id="test_choice" name="test[choice]" required="required">foo</option>
    <option value="1" id="test_choice" name="test[choice]" required="required">bar</option>
</select>

Options have the same attributes as select. Options shoud not have them.

I'm working on the latest version of 2.7 branch

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.