Skip to content
This repository has been archived by the owner on Jun 9, 2021. It is now read-only.

Forms with checkboxes that have a default value of false do not work #178

Closed
itay opened this issue Jan 3, 2017 · 5 comments
Closed

Forms with checkboxes that have a default value of false do not work #178

itay opened this issue Jan 3, 2017 · 5 comments

Comments

@itay
Copy link
Contributor

itay commented Jan 3, 2017

If I submit a form that looks like this:

[
        {   "name": "platforms",
            "label": "Platforms",
            "type": "checkbox", 
            "required": true,
            "buttonFormElementOptionList": [
                {"label": "Linux x64", "name": "linux_64", "defaultValue": true}, 
                {"label": "Darwin", "name": "darwin_64", "defaultValue": false},
....
}
]

The above false will get rewritten like this:

[
  {
    "description": "Which platforms to build",
    "label": "Platforms",
    "name": "platforms",
    "buttonFormElementOptionList": [
      {
        "label": "Linux x64",
        "name": "linux_64",
        "defaultValue": "true"
      },
      {
        "label": "Darwin",
        "name": "darwin_64",
        "defaultValue": "false"
      },

And because the string "false" is truth-y, it will get rendered as checked.

@itay
Copy link
Contributor Author

itay commented Jan 3, 2017

It's likely here: https://github.com/tomasbjerre/pull-request-notifier-for-bitbucket/blob/master/src/main/java/se/bjurr/prnfb/presentation/dto/ButtonFormElementOptionDTO.java#L14

It should either be a bool or the setXXX on it should take into account "false" and set it to null.

@tomasbjerre
Copy link
Owner

Released in 2.46. Thanks!

@itay
Copy link
Contributor Author

itay commented Jan 3, 2017

@tomasbjerre there is another bug (this one in my original change): https://github.com/tomasbjerre/pull-request-notifier-for-bitbucket/blob/master/src/main/resources/pr-triggerbutton.js#L81

The issue is that it shouldn't have the checked part at all, just like you see on the Radio one:
https://github.com/tomasbjerre/pull-request-notifier-for-bitbucket/blob/master/src/main/resources/pr-triggerbutton.js#L104

So things are still selected even if the default value is false. Here is a sample form (complete) for you to try:

[
        {   "name": "platforms",
            "label": "Platforms",
            "type": "checkbox", 
            "required": true,
            "buttonFormElementOptionList": [
                {"label": "Linux x64", "name": "linux_64", "defaultValue": true}, 
                {"label": "Darwin", "name": "darwin_64", "defaultValue": false},
                {"label": "Linux x86", "name": "linux_32", "defaultValue": false},
                {"label": "Windows x64", "name": "windows_64", "defaultValue": false},
                {"label": "Windows x86", "name": "windows_32", "defaultValue": false},
                {"label": "Linux 32-bit", "name": "linux_32", "defaultValue": false},
                {"label": "AIX", "name": "aix", "defaultValue": false},
                {"label": "FreeBSD9", "name": "freebsd", "defaultValue": false},
                {"label": "HPUX", "name": "hpux", "defaultValue": false},
                {"label": "Linux ARM", "name": "linux_arm", "defaultValue": false},
                {"label": "Linux PPC", "name": "linux_ppc", "defaultValue": false},
                {"label": "Linux PPC LE", "name": "linux_ppcle", "defaultValue": false},
                {"label": "Linux S390X", "name": "linux_s390x", "defaultValue": false},
                {"label": "Solaris SPARC", "name": "sunos_sparc", "defaultValue": false},
                {"label": "Solaris x64", "name": "sunos_64", "defaultValue": false}
            ],
            "description": "Which platforms to build"
        }
]

Only the Linux x64 option should be selected by default.

@tomasbjerre
Copy link
Owner

Ok, I just released 2.47 to fix that =)

@itay
Copy link
Contributor Author

itay commented Jan 3, 2017

Looks great - just verified!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants