Allow specifying a dynamic default value via a function
- Dominant language
- JavaScript
- Stars
- 19.4k
- Forks
- 3.1k
- Avg merge
- 1d 14h
- Merged PRs (30d)
- 9
Description
**- Do you want to request a *feature* or report a *bug*?**
*feature*
**- What is the current behavior?**
The default value of a field has to be a fixed string/number/boolean (depending on the field type).
**- What is the expected behavior?**
It would be great to be able specify a function that would return the desired value (maybe even allow it to return a promise for it, for even greater flexibility).
My use case is that I would like to generate `uuid`s for my collection entries and editor components, and store them in a field with `widget: 'hidden'`.
Would be great to be able to do something like:
```js
CMS.registerEditorComponent({
// ...
fields: [{
name: 'uuid',
label: 'UUID',
widget: 'hidden',
default() {
return generateUuid();
}
} /*, ... */ ]
});
```
Contributor guide
Assessment
This issue has not been assessed yet.