Closed
Description
All code tested on clean symfony 2.8 installation
I've created TestFormType
class TestType extends AbstractType
{
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder
->add('testChoice', 'choice', [
'choices' => [
1 => 'test 1',
2 => 'test 2',
3 => 'test 3',
],
'choice_attr' => [
1 => ['data-test' => 'test 1'],
2 => ['data-test' => 'test 2'],
3 => ['data-test' => 'test 3'],
],
]);
}
}
and i got this in view:
<select id="test_testChoice" name="test[testChoice]">
<option value="1">test 1</option>
<option value="2" data-test="test 1">test 2</option>
<option value="3" data-test="test 2">test 3</option>
</select>
same with placeholder option:
class TestType extends AbstractType
{
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder
->add('testChoice', 'choice', [
'choices' => [
1 => 'test 1',
2 => 'test 2',
3 => 'test 3',
],
'placeholder' => 'test placeholder',
'choice_attr' => [
1 => ['data-test' => 'test 1'],
2 => ['data-test' => 'test 2'],
3 => ['data-test' => 'test 3'],
],
]);
}
}
<select id="test_testChoice" name="test[testChoice]" required="required">
<option value="" selected="selected">test placeholder</option>
<option value="1">test 1</option>
<option value="2" data-test="test 1">test 2</option>
<option value="3" data-test="test 2">test 3</option>
</select>
i'm not sure, but i think problem near this commit: d94c322
probably in normalizeLegacyChoices method