Document how to set default value
- Dominant language
- Python
- Stars
- 102
- Forks
- 182
- PR merge metrics
- No merged PRs in 30d
Description
### 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"](https://github.com/ckan/ckanext-scheming/search?q=default) brought up https://github.com/ckan/ckanext-scheming/blob/d441d2dee72a7382a73de4185b01fae4b2d37473/ckanext/scheming/templates/scheming/package/snippets/resource_form.html#L31-L33
### 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 https://github.com/ckan/ckanext-scheming/issues/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 https://github.com/ckan/ckanext-scheming/issues/258)
```
/dataset/new?notes=some_default_notes
```
Contributor guide
No contributing guide indexed for this repository
Research direction
Start with the README, examples, and the linked resource_form.html snippet to confirm where schema behavior is documented. Add a friendly explanation of the three default-value methods, including the provided schema and URL examples; done means a reader can find and follow the guidance.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- documentation
- Issue type
- Documentation
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 55/100