Skip to content

[Form] Recall for choice group_by ordering #31593

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
ro0NL opened this issue May 23, 2019 · 10 comments
Closed

[Form] Recall for choice group_by ordering #31593

ro0NL opened this issue May 23, 2019 · 10 comments

Comments

@ro0NL
Copy link
Contributor

ro0NL commented May 23, 2019

When the choice_loader is built-in / out of scope, working with the choices can be a real pain. As such i'd like to recall for #21717 / #22136

Given

$form = $this->createForm(TimezoneType::class, null, [
    'intl' => true,
    'group_by' => function ($tz) {
        return Timezones::getGmtOffset($tz);
    },
]);

The UX is completely off due default ordering;

image

Perhaps this should be solved per type, but i tend to believe having some generic solution is nice. Or maybe there's a better way?

Moreover, as we deprecated the region/zone option; there's currently no sane alternative to apply such a filter. Consider #28624 for this :)

@ro0NL
Copy link
Contributor Author

ro0NL commented Jun 14, 2019

from #21717 (comment))

I'm -1 on this feature. The problem solved here can easily be solved by sorting the choices before passing them to the choices option (either with usort() or - better - in the database).

i figure the feature im seeking is a choice_order option.

@xabbuh
Copy link
Member

xabbuh commented Jul 21, 2019

I am not convinced we need this. The issue laid out in the initial description seems specific to some of the core types, isn't it? So solving the ordering there (as a bug fix) looks like the solution to me.

@ro0NL
Copy link
Contributor Author

ro0NL commented Jul 21, 2019

You're right, if we can do something for the core intl types that be great. Though i agree we probably dont want a generic choice_filter/order option. Solving it with choice_loader seems the better practice.

What about specific filter / order options for the intl types only?

@xabbuh
Copy link
Member

xabbuh commented Jul 22, 2019

Related to #11847 and #28624 then?

@ro0NL
Copy link
Contributor Author

ro0NL commented Jul 22, 2019

#11847 is solved by #28624 actually. But #28624 introduces a global choice_filter option, so perhaps something we don't want (as we've concluded here). Adding choice_filter only the intl choice types could work (i tend to believe a "callable" option is more powerful then a "list of values").

Another thing is (hence i've created this issue) the ordering of choices. If we use "group_by" we might need a different ordering to comply with the grouping (as demonstrated here with timezones)

So perhaps intl_filter + intl_order are the better options (tied to intl choice types).

@xabbuh
Copy link
Member

xabbuh commented Jul 22, 2019

Regarding your timezone example: Why would we want the choices to be ordered differently when they are grouped then without the grouping?

@ro0NL
Copy link
Contributor Author

ro0NL commented Jul 22, 2019

because for UX they should be ordered by GMT offset (from low to high)

@xabbuh
Copy link
Member

xabbuh commented Jul 22, 2019

But this order is fine for either case, isn't it?

@ro0NL
Copy link
Contributor Author

ro0NL commented Jul 22, 2019

not sure i understand, technically/semantically it doesnt matter (the same choices remain available)

however looking at

image

for UX the optgroups should go from ... -2, -1, 0, +1, +2, .... That's what im trying to solve now :)

@yceruto
Copy link
Member

yceruto commented Jul 22, 2019

The choice_order or choice_sort option for intl types only sounds good to me.

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

No branches or pull requests

3 participants