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

"false" should be a valid value for a "required" boolean checkbox #748

Open
ndbroadbent opened this issue Apr 16, 2020 · 1 comment
Open

Comments

@ndbroadbent
Copy link

I saw the docs for the Checkbox Field, and I think the code is not properly handling "required" fields:

required | boolean | Indicates whether the field's value is required. If set to true, the field must take on a valid value and cannot be left empty or unassigned.

When a checkbox is unchecked, this should set the field value to "false", and this should be considered a valid value. Right now I am unable to submit the form and the checkbox shows a validation error when it is unchecked.

(Might also be related to #528, but that issue didn't have enough context.)

@ndbroadbent
Copy link
Author

Ahhhh, this is the isEmpty function in ListField:

        isEmpty: function()
        {
            return this.data.length === 0;
        },

And Alpaca.Fields.CheckBoxField inherits from Alpaca.Fields.ListField.

Otherwise it would have worked fine if it used the isEmpty function from Field:

        isEmpty: function()
        {
            return Alpaca.isValEmpty(this.getValue());
        },

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

No branches or pull requests

1 participant