8000 Non unique choice labels are being stripped out (2.7) · Issue #16219 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content
8000

Non unique choice labels are being stripped out (2.7) #16219

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
trsteel88 opened this issue Oct 12, 2015 · 1 comment
Closed

Non unique choice labels are being stripped out (2.7) #16219

trsteel88 opened this issue Oct 12, 2015 · 1 comment

Comments

@trsteel88
Copy link
Contributor

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.

@trsteel88
Copy link
Contributor Author

Closing as I just found a duplicate issue #15606

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant
0