Created
January 25, 2021 20:20
-
-
Save amercader/b7f393223f01908c7954dcb9b09acd30 to your computer and use it in GitHub Desktop.
Sections in form with ckanext-scheming
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"dataset_fields": [ | |
{ | |
"section": "Basic Metadata", | |
"field_name": "title", | |
"label": "Title", | |
"...": "..." | |
}, | |
{ | |
"section": "Data Privacy and Sharing", | |
"section_subtitle": "Only applies to data that is uploaded to the portal", | |
"name": "privacy_regulated", | |
"...": "..." | |
} | |
] | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{% ckan_extends %} | |
{% block basic_fields %} | |
{%- if not dataset_type -%} | |
<p> | |
dataset_type not passed to template. your version of CKAN | |
might not be compatible with ckanext-scheming | |
</p> | |
{%- endif -%} | |
{%- set schema = h.scheming_get_dataset_schema(dataset_type) -%} | |
<!-- Custom --> | |
{%- for field in schema.dataset_fields -%} | |
{% if field.section %} | |
<h2>{{ field.section }}</h2> | |
{% endif %} | |
{% if field.section_subtitle %} | |
<p class="scheming-section-subtitle">{{ field.section_subtitle }}</p> | |
{% endif %} | |
<!-- End Custom --> | |
{%- if field.form_snippet is not none -%} | |
{%- snippet 'scheming/snippets/form_field.html', | |
field=field, data=data, errors=errors, licenses=c.licenses, | |
entity_type='dataset', object_type=dataset_type -%} | |
{%- endif -%} | |
{%- endfor -%} | |
{%- if 'resource_fields' not in schema -%} | |
<!-- force controller to skip resource-editing step for this type --> | |
<input type="hidden" name="_ckan_phase" value="" /> | |
{%- endif -%} | |
{% resource 'gdx/privacy-fields.js' %} | |
{% endblock %} | |
{% block metadata_fields %} | |
{% block package_metadata_fields_custom %} | |
{% block custom_fields %} | |
<h2>Custom Fields</h2> | |
{% snippet 'snippets/custom_form_fields.html', extras=data.extras, errors=errors, limit=3 %} | |
{% endblock %} | |
{% endblock %} | |
{% endblock %} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment