Closed
Description
I am running Symfony 2.7 and I have found that non unique form choice labels are being removed from my choices. I have a choice which shows labels in a parent/child format. e.g:
- Header Nav
- Page 1
- Page 2
- Page 3
- Footer Nav
- Page 1
- Page 2
- Page 4
In the above example, "Page 1" and "Page 2" are stripped from the choice because it isn't unique. However, the actual ID within the choice is different.
I have created an example of this from the Symfony Standard repo: https://github.com/trsteel88/symfony-standard/tree/unique-choices-bug
Here is the form:
$form = $this->createFormBuilder(array())
->add('choice', 'choice', array(
'mapped' => false,
'choices' => array(
1 => 'Header Nav',
2 => ' - Page 1',
3 => ' - Page 2',
4 => ' - Page 3',
5 => 'Footer Nav',
6 => ' - Page 1',
7 => ' - Page 2',
8 => ' - Page 4',
)
))
->getForm()
;
Here is the output:
<select id="form_choice" name="form[choice]">
<option value="1" >Header Nav</option>
<option value="6" > - Page 1</option>
<option value="7" > - Page 2</option>
<option value="4" > - Page 3</option>
<option value="5" >Footer Nav</option>
<option value="8" > - Page 4</option>
</select>
You will notice that the id for "2" and "3" is now missing, and it has been shifted up and is sitting in the wrong position.
Metadata
Metadata
Assignees
Labels
No labels