Hello all,
anyone knows, how I can set default values for the taxonomy field. Also changing the label text, would be nice.
Apart from that. What is the difference / advantage over using a normal selectize field for adding categories/tags?
Hello all,
anyone knows, how I can set default values for the taxonomy field. Also changing the label text, would be nice.
Apart from that. What is the difference / advantage over using a normal selectize field for adding categories/tags?
Okay, for the last part of my question. It is more a select (list) field showing all your already applied categories and tags to choose from. Now I get it.
Taxonomy extends the standard select field. You can see the extra logic here:
{% set taxonomies = (taxonomies is null ? admin.data('config/site').taxonomies : taxonomies) %}
{% set parentname = field.name %}
{% for name in taxonomies %}
{% set value = array(data.value('header.taxonomy.' ~ name)|default([])) %}
{% set sub_taxonomies = attribute(grav.taxonomy.taxonomy, name)|default([])|keys %}
{% set list = []|merge(sub_taxonomies)|merge(value)|array_unique %}
{% set field = {
type: 'select',
classes: 'fancy create',
label: name|capitalize,
name: parentname ~ '.' ~ name,
multiple: true,
options: list,
style: field.style,
selectize: {
create: true
}
} %}
{% include ['forms/fields/select/select.html.twig'] %}
{% endfor %}
You can’t really set defaults from the field, because the taxonomy is coming directly from the configured taxonomy as defined in the system.yaml.
Is there somewhere else a default taxonomy value can be set for certain blueprints or children in a collection?
I see here in the Blueprints Documentation that taxonomy appears to accept a default value, but I’m not quite sure how to appropriately set it. For example, if using a taxonomy of “categories”, and I wanted to set that to “foo” in a specific blueprint, how could I do that?
It seems like otherwise the only option is to use a custom header field that can be defaulted, though I’m not sure if taxonomies are inherently more efficient than than using that method.