Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix checkboxes checked state #470

Closed
wants to merge 1 commit into from
Closed

Conversation

NicoHood
Copy link
Contributor

@NicoHood NicoHood commented Jan 7, 2021

This is a long standing issue (7 years) for checkbox default values when use: keys is not used. The default values are still specified in a named array defaultvalue => keyname but the code assumes a flat array. When setting a default value of false the code will fail. You can test this using:

my_field:
    type: checkboxes
    label: A couple of checkboxes
    default:
        option1: true
        option2: false
    options:
        option1: Option 1
        option2: Option 2

Edit: It seems there is more broken. I will work on that and edit.

This is a long standing issue (7 years) for checkbox default values when `use: keys` is **not** used. The default values are still specified in a named array `defaultvalue => keyname` but the code assumes a flat array. When setting a default value of `false` the code will fail. You can test this using:

```yaml
my_field:
    type: checkboxes
    label: A couple of checkboxes
    default:
        option1: true
        option2: false
    options:
        option1: Option 1
        option2: Option 2
```
@NicoHood
Copy link
Contributor Author

NicoHood commented Jan 7, 2021

I will close this for now, as the issue itself must be reevaluated: #471

@NicoHood NicoHood closed this Jan 7, 2021
@mahagr
Copy link
Member

mahagr commented Jan 8, 2021

You cannot do that. If you're not using keys, default is something like this:

default:
  - option1
  - option2

@mahagr mahagr added the invalid label Jan 8, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants