New-UDInputField checkbox saving checked value when unchecked

So I’m working with a Form that will allow my Developers to publish content to our web farm and have a single checkbox that will allow them to encrypt the web config of their app if checked and leave it as plain text if left unchecked.

The problem I’m having is in testing this it seems that if I run the tool to encrypt the first time and then decrypt the web config and try to run it as plain text the next time the variable for the checkbox is reading as still checked and the web config is encrypted.

From the documentation for InputFields I built it like:

New-UDInputField - Type 'checkbox' -Name 'EncryptConfig' -Placeholder 'Encrypts Web Config if Checked'

Then within the tool I’m validating via an if statement:

if ($EncryptConfig){...Encrypt the Config...}

Is there anything I’m missing here? I’ve even gone as far as to set the $EncryptConfig variable to nothing once it’s passed the if validation.

I figured my initial post might be vague so I’ve been testing and built a simple checkbox test tool based entirely off of the documentation for the checkbox input.

    New-UDCard -Title "CheckBox Testing" -Content {
        New-UDInput @Colors -Title "Checkbox Input Testing" -Id "CheckboxForm" -Content{
            New-UDInputField -Type 'textbox' -Name 'name' -Placeholder 'Enter Your Name'
            New-UDInputField -Type 'checkbox' -Name 'check' -Placeholder 'Yes?'
        } -Endpoint {
            param($name, $check)

            if ($check){
                New-UDInputAction -Toast "Yes, $Name"
            }
            else {
                New-UDInputAction -Toast "No, $Name"
            }
            #$check = ""
        }
     }

So what I’ve found is the checkbox ‘variable’ is being saved after it is ran intially. So if you run it initially with it checked you get an output of "Yes, $Name" and then if you run it again after and leave the checkbox unchecked you will still get the same "Yes, $Name" output. I’m probably just stupid and missing something very obvious here but I just can’t figure it out. Do I need to have the page refreshed everytime I run any form with a checkbox involved?

1 Like

This seems like a bug to me. Can you please file an issue on GitHub?

1 Like

I am noticing the same result - I have a dashboard running the latest nightly build (testing cache and session enhancements) and found that none of my check boxes state change. when i click the check box i see the toast “true” but when i click it again the toast still says true.

And the check in the box is not appearing its just staying blank.

Just to be clear, this is using New-UDInput and not New-UDCheckbox?

apologies - i am using New-UDCheckbox with the results I posted.

@adamdriscoll yes mine is New-UDInputField -type ‘checkbox’

I’ll get something posted to GitHub about it.

What is the first difference between New-UDInputField with -type ‘checkbox’ and just New-UDCheckbox?