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

wip: Add validator for null form_snippets to prevent removing values. #243

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

boykoc
Copy link
Contributor

@boykoc boykoc commented May 7, 2020

When using ckanext-scheming you are able to add a field to your schema but have it hidden in the web form UI by using "form_snippet": null. However, when a user edits the package the value/key are removed from the package object.

This validator allows you to hide the form_snippet without losing the value of the field. This does not create a read only version as in this use-case, the desire is to just not lose the existing value for "hidden" form fields. A read only value may require its own validator to prevent editing if a value is provided. This validator allows editing of the value via an API call for instance.

I've suggested this for scheming as the hidden form aspect that it's tied to is here instead CKAN core.

This was more or less lifted from ckanext-canada.

Related PRs / Issues:
PR #168
Issue #66
ckan/ckan#1839 (comment)

@wardi
Copy link
Contributor

wardi commented May 7, 2020

this won't work for resource fields, group/org fields or fields that are part of the original package schema. I think this feature would be better implemented in ckan core package_update by adding the original dict to the context passed through to validators.

@boykoc
Copy link
Contributor Author

boykoc commented May 7, 2020

Thanks for the feedback. True on not working for certain fields.

I'm going to leave here just until I get a working version for ckan core as suggested.

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

Successfully merging this pull request may close these issues.

None yet

2 participants