Closed jgonyea closed 2 years ago
Using the following blueprint:
my_field: type: select classes: fancy options: "option1": value: Option 1 "option2": value: Option 2 "option3": disabled: true value: My Disabled Option default: option1
I believe the select field twig has two bugs in it when the options are iterable (see above).
The first is at L46:
{{ item_value.selected ? 'selected="selected"' : '' }}
This will not properly load/ select the iterable stored data. To fix, I believe the line should look like:
{{ item_value.selected or key == value ? 'selected="selected"' : '' }}
This will take into consideration a manually selected option as well as when the option is set from loaded data.
The second related bug is at L48:
value="{{ item_value.akey }}"
akey is calculated at L43, but isn't referenced properly. I believe the L48 line should read:
akey
value="{{ akey }}"
Changing L48 will set the proper key in a form based on the key in the options array.
PR submitted: https://github.com/getgrav/grav-plugin-form/pull/558
Using the following blueprint:
I believe the select field twig has two bugs in it when the options are iterable (see above).
Bug1: Saved data not loaded into form on page refresh.
The first is at L46:
This will not properly load/ select the iterable stored data. To fix, I believe the line should look like:
This will take into consideration a manually selected option as well as when the option is set from loaded data.
Bug2: Option key is not stored properly
The second related bug is at L48:
akey
is calculated at L43, but isn't referenced properly. I believe the L48 line should read:Changing L48 will set the proper key in a form based on the key in the options array.