Fixed taxonomy field not listing existing options in Flex Pages

This commit is contained in:
Matias Griese
2020-12-23 21:07:23 +02:00
parent a0fce62e31
commit 8e157bac5a
2 changed files with 7 additions and 1 deletions

View File

@@ -6,6 +6,7 @@
1. [](#bugfix) 1. [](#bugfix)
* Fixed missed highlight on the selected page in Parents field * Fixed missed highlight on the selected page in Parents field
* Fixed notifications that would not be remembered as hidden * Fixed notifications that would not be remembered as hidden
* Fixed taxonomy field not listing existing options in Flex Pages
* Fixed taxonomy field not working outside pages * Fixed taxonomy field not working outside pages
# v1.10.0-rc.20 # v1.10.0-rc.20

View File

@@ -1,6 +1,7 @@
{% extends "forms/field.html.twig" %} {% extends "forms/field.html.twig" %}
{% block field %} {% block field %}
{% set object = form.object %}
{% set taxonomies = taxonomies ?? field.taxonomies ?? admin.data('config/site').taxonomies ?? [] %} {% set taxonomies = taxonomies ?? field.taxonomies ?? admin.data('config/site').taxonomies ?? [] %}
{% set parentname = field.name %} {% set parentname = field.name %}
{% set options = field.options %} {% set options = field.options %}
@@ -9,7 +10,11 @@
{% for name in taxonomies %} {% for name in taxonomies %}
{% set field_name = parentname ~ '.' ~ name %} {% set field_name = parentname ~ '.' ~ name %}
{% set value = (form.value(field_name) ?? data.value(field_name) ?? default[name] ?? [])|array %} {% set value = (form.value(field_name) ?? data.value(field_name) ?? default[name] ?? [])|array %}
{% set sub_taxonomies = (attribute(grav.taxonomy.taxonomy, name) ?? [])|keys %} {% if object %}
{% set sub_taxonomies = object.getFlexDirectory().getIndex().getDistinctValues(field_name) %}
{% else %}
{% set sub_taxonomies = (attribute(grav.taxonomy.taxonomy, name) ?? [])|keys %}
{% endif %}
{% set list = (options[name] ?? [])|merge(sub_taxonomies)|merge(value)|array_unique %} {% set list = (options[name] ?? [])|merge(sub_taxonomies)|merge(value)|array_unique %}
{% set field = { {% set field = {