Pass dataset name to resource fields snippets #354
Merged
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.
@wardi this is just some proposal for discussion
Resource field snippets in the new form have no way of knowing the dataset id/name (if it's an edit form there is
data.package_id
).These changes are not the most elegant, because 1) they add a resource-specific key to the generic
form_field.html
and 2) they pass the dataset name instead of the id.This is because, annoyingly, upstream CKAN core only passes the name from
new_resource.html
/new_resource_not_draft.html
toresource_form.html
, and notpkg_dict
, so that's the only thing available to ckanext-scheming to pass on.Should we patch the linked core templates to pass the whole
pkg_dict
toresource_form.html
?Is there a simpler approach that I'm missing?
For context, we are using this in ckan/ckanext-validation#83, where we are creating a new frontend component to upload files that targets an endpoint that must know the dataset id to create the resource properly.