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

Fixed multiple select optgroup selected bug #276

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@
data-key-observe="{{ (scope ~ field.name)|fieldName }}"
{% endif %}
>
{% if field.placeholder %}<option value="" disabled selected>{% if grav.twig.twig.filters['tu'] is defined %}{{ field.placeholder|tu|raw }}{% else %}{{ field.placeholder|t|raw }}{% endif %}</option>{% endif %}
{% set selectedoption = false %}
{% if field.placeholder %}<option value="" disabled selected>{% set selectedoption = true %}{% if grav.twig.twig.filters['tu'] is defined %}{{ field.placeholder|tu|raw }}{% else %}{{ field.placeholder|t|raw }}{% endif %}</option>{% endif %}

{% for key, optgroup in field.options %}
{% set optgroup_label = optgroup|keys|first %}
Expand All @@ -31,7 +32,7 @@
{%for subkey, suboption in field.options[key][optgroup_label] %}
{% set selected = field.selectize ? suboption : subkey %}
{% set item_value = field.selectize and field.multiple ? suboption : subkey %}
<option {% if subkey == value or (field.multiple and selected in value) %}selected="selected"{% endif %} value="{{ suboption }}">
<option {% if selectedoption == false and subkey == value or (field.multiple and selected in value) %}{% set selectedoption = true %}selected="selected"{% endif %} value="{{ suboption }}">
{% if grav.twig.twig.filters['tu'] is defined %}
{{ suboption|tu|raw }}{% else %}{{ suboption|t|raw }}
{% endif %}
Expand Down