Skip to content
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

Time Zone form field to use groupedlist fancy select layout #42774

Merged
merged 9 commits into from
Mar 4, 2024
1 change: 1 addition & 0 deletions administrator/components/com_config/forms/application.xml
Original file line number Diff line number Diff line change
Expand Up @@ -454,6 +454,7 @@
label="COM_CONFIG_FIELD_SERVER_TIMEZONE_LABEL"
description="COM_CONFIG_FIELD_SERVER_TIMEZONE_DESC"
default="UTC"
layout="joomla.form.field.groupedlist-fancy-select"
>
<option value="UTC">JLIB_FORM_VALUE_TIMEZONE_UTC</option>
</field>
Expand Down
1 change: 1 addition & 0 deletions administrator/components/com_users/forms/user.xml
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,7 @@
name="timezone"
type="timezone"
label="COM_USERS_USER_FIELD_TIMEZONE_LABEL"
layout="joomla.form.field.groupedlist-fancy-select"
>
<option value="">JOPTION_USE_DEFAULT</option>
</field>
Expand Down
1 change: 1 addition & 0 deletions components/com_users/forms/frontend.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
name="timezone"
type="timezone"
label="COM_USERS_USER_FIELD_TIMEZONE_LABEL"
layout="joomla.form.field.groupedlist-fancy-select"
>
<option value="">JOPTION_USE_DEFAULT</option>
</field>
Expand Down
5 changes: 4 additions & 1 deletion libraries/src/Form/Field/GroupedlistField.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,10 @@ class GroupedlistField extends FormField
protected function getGroups()
{
$groups = [];
$label = 0;
$label = ($this->layout == 'joomla.form.field.groupedlist-fancy-select') ? '' : 0;
cyrezdev marked this conversation as resolved.
Show resolved Hide resolved
// To be able to display an out-of-group option when using grouped list with fancy-select,
// this one should be in an empty group. This allows you to have a placeholder option with a non-empty value.
// Choices.js issue about mixed options with optgroup: https://github.com/Choices-js/Choices/pull/1110

foreach ($this->element->children() as $element) {
switch ($element->getName()) {
Expand Down