The extra options render at the top of the site pages list just fine. However, for the custom options, the option value doesn't match the field value, so the select shows the first option in the list and that is saved next time the page is saved.
I looked at the template on line 8 and noticed that there is no check for the existing field value on custom options, so its selected attribute would never be selected.
I changed this to:
{% for key, label in field.options %}
<option {% if key == value or (field.multiple and key in value) %}selected="selected"{% endif %} value="{{ key|e('html_attr') }}">{{ label|t }}</option>
{% endfor %}
expecting it to work. (I renamed the iterated value to label because value was messing with my head!)
Then I noticed the and depth == 0 above, couldn't see where depth was, and eliminated it too. Still not working.
When I add dump(key, value) inside the loop to see which values are being compared, everything seems in order. The values equal. I also added a dump inside the test and it did output when the values are equal. So the selected attribute is likely being added. Perhaps something is happening in the selectize JS??
So I thought it might be a simple oversight bug that I could fix, but there's more to it. :confounded: Any ideas?
Apologies if this has been logged already, it's pretty difficult to precisely search issues for "pages".
I have added some custom external pages to my Pages field. If it makes any difference, it's within a list.
The extra options render at the top of the site pages list just fine. However, for the custom options, the option value doesn't match the field value, so the select shows the first option in the list and that is saved next time the page is saved.
I looked at the template on line 8 and noticed that there is no check for the existing field value on custom options, so its
selected
attribute would never be selected.I changed this to:
expecting it to work. (I renamed the iterated value to
label
becausevalue
was messing with my head!)Then I noticed the
and depth == 0
above, couldn't see wheredepth
was, and eliminated it too. Still not working.When I add
dump(key, value)
inside the loop to see which values are being compared, everything seems in order. The values equal. I also added adump
inside the test and it did output when the values are equal. So theselected
attribute is likely being added. Perhaps something is happening in the selectize JS??So I thought it might be a simple oversight bug that I could fix, but there's more to it. :confounded: Any ideas?