wip: Add validator for null form_snippets to prevent removing values. #243
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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)