Boolean is shown as required even though it has a default
See original GitHub issueDescribe the bug When you setup a boolean field, and have other fields that are required, the boolean shows an error message even though it has a default.
To Reproduce
- Create a boolean widget
- Create an input widget.
- Create a new entry, fill nothing in, click Publish.
- Notice the UI tells you both fields are required
- Fill in the input widget
- Press publish
- Notice bool still shows error
- Turn bool on, turn bool back off
- Press publish, notice it saves now.
Expected behavior I shouldn’t have to turn a bool from false(default), to true, to false
Screenshots
Applicable Versions:
- Netlify CMS version: 2.10.26
- Git provider: github
- OS: Mac
- Browser version Chrome 80.0
- Node.JS version: 10.17.0
CMS configuration
backend:
name: git-gateway
branch: master
media_folder: static/img/content
public_folder: /img/content
collections:
- name: 'blog'
label: 'Blog'
format: 'json'
folder: 'assets/content/blog'
create: true
slug: '{{slug}}'
editor:
preview: false
fields:
- label: 'Published'
name: 'isPublished'
widget: 'boolean'
- label: 'Icon'
name: 'icon'
widget: 'select'
options: ['VUE', 'NUXT']
- label: 'Publish Date'
name: 'date'
widget: 'datetime'
- label: 'title'
name: 'title'
widget: 'string'
- label: 'Description'
name: 'description'
- label: 'thumb'
name: 'thumb'
widget: 'object'
fields:
- label: 'Url'
name: 'url'
widget: 'image'
media_library:
config:
multiple: false
- label: 'Alt'
name: 'alt'
- label: 'Body'
name: 'body'
widget: 'list'
types:
- label: 'Code Block'
name: 'codeBlock'
widget: 'object'
fields:
- label: 'Title'
name: 'title'
- label: 'Style'
name: 'style'
widget: 'select'
options: ['GOOD', 'BAD', 'NORMAL']
default: 'NORMAL'
- label: 'Code'
name: 'code'
widget: 'markdown'
- label: 'Image'
name: 'image'
fields:
- label: 'Url'
name: 'url'
widget: 'image'
- label: 'Alt'
name: 'alt'
widget: 'string'
- label: 'Markdown'
name: 'markdown'
fields:
- label: 'Content'
name: 'content'
widget: 'markdown'
- label: 'YouTube Video'
name: 'youTubeVideo'
fields:
- label: 'ID'
name: 'id'
widget: 'string'
Issue Analytics
- State:
- Created 4 years ago
- Reactions:1
- Comments:7 (7 by maintainers)
Top Results From Across the Web
Default value of 'boolean' and 'Boolean' in Java - Stack Overflow
The default value for a Boolean (object) is null . The default value for a boolean (primitive) is false .
Read more >Boolean Data Type - Visual Basic | Microsoft Learn
Use the Boolean Data Type (Visual Basic) to contain two-state values such as true/false, yes/no, or on/off. The default value of Boolean is ......
Read more >Form fields - Django documentation
Since all Field subclasses have required=True by default, the validation condition here is important. If you want to include a boolean in your...
Read more >Python Booleans: Optimize Your Code With Truth Values
The Python Boolean type has only two possible values: True; False. No other value will have bool as its type. You can check...
Read more >BooleanField - Django Models - GeeksforGeeks
It is like a bool field in C/C+++. The default form widget for this field is CheckboxInput, or NullBooleanSelect if null=True. The default...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Ah so the default in the docs is really only used when the field isn’t required. Otherwise the default really doesn’t qualify as filled for required fields… 😃
I think just some tweaks in the docs would be fine for now.
LOL, such a simple change, but a world of difference. Thanks @erezrokah !