FusionAuth
    • Home
    • Categories
    • Recent
    • Popular
    • Pricing
    • Contact us
    • Docs
    • Login

    Checkbox custom form field works weird

    Scheduled Pinned Locked Moved
    Comments & Feedback
    0
    4
    1.2k
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • I
      ishuvalov
      last edited by

      After upgrading from 1.19 to 1.22.1 when I try to create form field as Checkbox control of type Boolean and assign its value to user.data.subscribe, FusionAuth forces me to provide a list of options. I believe it should work just as single boolean value: true or false.

      Screenshot 2020-12-10 at 16.05.58.png

      1 Reply Last reply Reply Quote 0
      • danD
        dan
        last edited by

        We need to update the documentation about this. We had some internal discussions about what to do with this case, which I agree, is a bit weird. Eventually we decided that what you see was the best option.

        The only allowed values are true and false. In theory you could have a checkbox of boolean with only one value of true (or one value of false), so by allowing them to enter the values, they can make this choice.

        --
        FusionAuth - Auth for devs, built by devs.
        https://fusionauth.io

        1 Reply Last reply Reply Quote 0
        • I
          ishuvalov
          last edited by

          Thank you for the clarification! It still looks a bit odd. For example if you provide both options, true and false, for the single Checkbox field, you will actually see two checkboxes on the form. And even can check them both.
          Screenshot 2020-12-14 at 13.20.19.png

          And the value in you custom data becomes not boolean, but array of booleans.
          Screenshot 2020-12-14 at 13.21.37.png

          Still it does what I need and even more. I have problems with Complete Registration form: it just crashes when the Self-consent field is the only field required to complete registration (will open the Issue on GitHub).
          But now if you set the only one option (true) for the Checkbox field and make it required, it can nicely serve as a Consent field.

          1 Reply Last reply Reply Quote 1
          • danD
            dan
            last edited by

            After some further thought, I believe this is working as designed, though I agree this is weird.

            When you create a checkbox and provide options, we display each option as a choice.

            If you didn't want it to display true or false you could create a messages entry for that field. (In the theme admin section; more here: https://fusionauth.io/blog/2020/09/01/theme-registration-form/ ).

            But I agree, I think in general you don't want to use checkboxes with multiple booleans, a select box is a better choice.

            --
            FusionAuth - Auth for devs, built by devs.
            https://fusionauth.io

            1 Reply Last reply Reply Quote 1
            • First post
              Last post