I am trying to create a custom field that would behave like the Tags field, i.e., with autocomplete for existing tags, and the ability to add new tags if desired, except that the field would work with a specific vocabulary rather than the default tags vocabulary.
To that end, I have:
Created the vocabulary with the vocabulary_create action.
Defined the field as follows in my dataset schema:
- field_name: dimension
label: Dimensions
form_placeholder: eg. Age Groups, Mother Tongue, First Official Language Spoken
validators: ignore_missing tag_string_convert
classes:
- control-full
form_attrs:
data-module: autocomplete
data-module-tags:
data-module-source: /api/2/util/tag/autocomplete?vocabulary_id=dimension&incomplete=?
class:
(This takes advantage of the autocomplete API accepting the vocabulary_id parameter).
With that field definition, autocomplete searches the desired vocabulary, and new tags can be entered.
However, the part I'm not figuring out is how to get new tags to be saved in the proper vocabulary. At this point, new tags are always saved in the default tags vocabulary (with an empty vocabulary id). Ideas?
I am trying to create a custom field that would behave like the Tags field, i.e., with autocomplete for existing tags, and the ability to add new tags if desired, except that the field would work with a specific vocabulary rather than the default tags vocabulary.
To that end, I have:
vocabulary_create
action.(This takes advantage of the autocomplete API accepting the
vocabulary_id
parameter).With that field definition, autocomplete searches the desired vocabulary, and new tags can be entered.
However, the part I'm not figuring out is how to get new tags to be saved in the proper vocabulary. At this point, new tags are always saved in the default tags vocabulary (with an empty vocabulary id). Ideas?