decaporg / decaporg/decap-cms

RegisterEditorComponent (custom widget) FIELDS - Required not working

Open
#6,986 1 comment 1 reaction 0 assignees View on GitHub
area: extensions/editor-components type: bug
Dominant language
JavaScript
Stars
19.4k
Forks
3.1k
Avg merge
1d 14h
Merged PRs (30d)
9

Description

**Describe the bug**
The 'required' and 'pattern' for custom widgets is not working.
It shouldn't allow to save the updates if all required fields are not filled.
![image](https://github.com/decaporg/decap-cms/assets/13559642/a8c2e18b-e9e1-4222-8b50-793db962c1fa)

**To Reproduce**
1. Create a custom widget using CMS.registerEditorComponent
2. Set a field as required: true
3. Insert the widget inside the markdown and don't fill the required field
4. Save the updates

`
window.CMS.registerEditorComponent({
id: 'collection',
label: 'Collection',
collapsed: true,
fields: [
{
label: 'Cards',
name: 'cards',
widget: 'list',
fields: [
{
label: 'Title',
name: 'title',
widget: 'string',
required: true,
},
]
`

**Expected behavior**
Won't allow save the updates since the field is mandatory.

**Applicable Versions:**
- netlify-cms-app 2.15.72
- netlify-cms-core 2.55.2
- netlify-cms 2.10.192
- Git provider: gitlab
- OS: windows 10
- Node.JS version: 16.16

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.