Skip to content

[Form] Keep preferred_choices order for choice groups #34083

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

Merged
merged 1 commit into from
Nov 28, 2019

Conversation

vilius-g
Copy link
Contributor

Q A
Branch? 4.3
Bug fix? yes
New feature? no
Deprecations? no
Tickets
License MIT
Doc PR

Since 4.3 ordering of preferred_choices is preserved when displaying form. But this only works for flat options. When the choices are grouped, the preferred groups are in default order.

Now the preferred choice group order is derived by taking the first matching choice from preferred_choices and using its position to sort the groups.

@vilius-g vilius-g force-pushed the optgroup-preffered-ordering branch from bf793b2 to 97ed3bf Compare October 23, 2019 13:20
@nicolas-grekas nicolas-grekas added this to the 4.3 milestone Oct 23, 2019
@xabbuh xabbuh added the Form label Oct 24, 2019
Copy link
Member

@nicolas-grekas nicolas-grekas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(with minor CS comment)

Copy link
Contributor

@HeahDude HeahDude left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@nicolas-grekas nicolas-grekas changed the title Keep preferred_choices order for choice groups [Form] Keep preferred_choices order for choice groups Nov 28, 2019
@nicolas-grekas nicolas-grekas force-pushed the optgroup-preffered-ordering branch from 8afaaff to 75404e5 Compare November 28, 2019 11:24
@nicolas-grekas
Copy link
Member

Thank you @vilius-g.

nicolas-grekas added a commit that referenced this pull request Nov 28, 2019
…ius-g)

This PR was squashed before being merged into the 4.3 branch.

Discussion
----------

[Form] Keep preferred_choices order for choice groups

| Q             | A
| ------------- | ---
| Branch?       | 4.3
| Bug fix?      | yes
| New feature?  | no
| Deprecations? | no
| Tickets       |
| License       | MIT
| Doc PR        |

Since 4.3 ordering of `preferred_choices` is preserved when displaying form. But this only works for flat options. When the choices are grouped, the preferred groups are in default order.

Now the preferred choice group order is derived by taking the first matching choice from `preferred_choices` and using its position to sort the groups.

Commits
-------

75404e5 [Form] Keep preferred_choices order for choice groups
@nicolas-grekas nicolas-grekas merged commit 75404e5 into symfony:4.3 Nov 28, 2019
This was referenced Dec 1, 2019
@vilius-g vilius-g deleted the optgroup-preffered-ordering branch February 1, 2020 11:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants