question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Boolean is shown as required even though it has a default

See original GitHub issue

Describe 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

  1. Create a boolean widget
  2. Create an input widget.
  3. Create a new entry, fill nothing in, click Publish.
  4. Notice the UI tells you both fields are required
  5. Fill in the input widget
  6. Press publish
  7. Notice bool still shows error
  8. Turn bool on, turn bool back off
  9. Press publish, notice it saves now.

Expected behavior I shouldn’t have to turn a bool from false(default), to true, to false

Screenshots image

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:closed
  • Created 4 years ago
  • Reactions:1
  • Comments:7 (7 by maintainers)

github_iconTop GitHub Comments

2reactions
hecktarzulicommented, Mar 18, 2020

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.

1reaction
hecktarzulicommented, Mar 19, 2020

LOL, such a simple change, but a world of difference. Thanks @erezrokah !

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found