Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tags-like field with open vocabulary #358

Open
davidlesieur opened this issue Jan 29, 2023 · 1 comment
Open

Tags-like field with open vocabulary #358

davidlesieur opened this issue Jan 29, 2023 · 1 comment

Comments

@davidlesieur
Copy link

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?

@davidlesieur
Copy link
Author

Does ckanext-scheming actually supports what I'm trying to achieve? Thanks.

@davidlesieur davidlesieur changed the title Tags-like field with custom open vocabulary Tags-like field with open vocabulary Feb 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant