ckanext-scheming icon indicating copy to clipboard operation
ckanext-scheming copied to clipboard

tag_string Field Mandatory

Open HilariousGil opened this issue 7 years ago • 1 comments

Hi,

I can't seem to make Tag's mandatory to fill in without causing other issues.

In my schema the field tag_string looks like this: { "field_name": "tag_string", "label": "Tags", "preset": "tag_string_autocomplete", "required": true }

The option "required: true" makes the default red * show up next to the field, but does not enforce any type of validation. For example if you leave the field blank, there will be no validation errors.

I see on the preset code that there is the "ignore_missing" validator, and I tried to replace it for the "not_empty" one.

This at first seemed to be working great, until I try to upload a resource, and when submitting the resource form, I got prompted with the following error:

tag error

Any suggestion?

HilariousGil avatar Oct 31 '18 13:10 HilariousGil

In ckan the package_update method takes both "tags" and "tag_string" values and converts the "tag_string" to "tags" inside the action, so the next time the dataset is updated the "tag_string" won't be set but the "tags" value will.

If you want to use the core tags field and you want to make it mandatory you need a validator that checks for values in either "tags" or "tag_string".

If you'd like to implement that validator and add it to scheming that would help other users in the same situation. I never worked on this because we use fluent_tags fields on our site and not the core tags field.

wardi avatar Oct 31 '18 15:10 wardi