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

Document how to set default value #339

Open
florianm opened this issue Aug 4, 2022 · 0 comments
Open

Document how to set default value #339

florianm opened this issue Aug 4, 2022 · 0 comments

Comments

@florianm
Copy link
Contributor

florianm commented Aug 4, 2022

Problem

I would like to set a default for some fields.

Research

Read README, examples, issues, browsed code, no definite pointer.

Searching the ckanext-scheming repo for "default" brought up

{% elif field.default %}
{% do data.__setitem__(field.field_name, field.default) %}
{% endif %}

Suggestions

The docs and examples could have a friendly pointer on how to set defaults, such as:

There are three ways to choose a default value.

First, if required is set on a choices list, the first option will be selected. (HT @jqnatividad #265)

Second, the key default sets an explicit default, and works on any field. The value must be valid as per the field's datatype and validators, or exist in the choices.

- field_name: license_id
  label: License
  display_property: dcat:Dataset/dcat:distribution/dcat:Distribution/dct:license
  form_snippet: license.html
  default: "cc-by-sa"

Third, field values can be supplied through GET request parameters to "Add dataset". (HT @wardi #258)

/dataset/new?notes=some_default_notes
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

No branches or pull requests

1 participant