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

When Creating A Form Builder, How do I make the checkbox multiple select to be true as default? #769

Open
JenuelDev opened this issue Nov 19, 2021 · 1 comment

Comments

@JenuelDev
Copy link

When Creating A Form Builder, How do I make the checkbox multiple select to be true as default?
image

@ZaLiTHkA
Copy link

ZaLiTHkA commented Jan 12, 2022

you're likely to get a better answer than this if you post your current schema/options objects... however, since you talk about "checkbox multiple select", I'm going to hazard a guess and say you're trying to do something like "checkbox" input example 7.

basically, if you have an "array" of "strings" in the schema, with the fields set as "checkbox" in the options, you need to have the associated data entry as an array of the string values relating to the items that are "checked".

edit: might be easier to explain with comments in example 7's code snippet..

$("#field7").alpaca({
    "schema": {
        "type": "object",
        "properties": {
            "checkboxArrayEnum": {
                "type": "array", // <--- this makes the control show an array of items
                "items": {
                    "type": "string", // <--- this tells each item that it's value is a string
                    "enum": ["option1", "option2", "option3"]
                }
            }
        },
        "required": ["checkboxArrayEnum"]
    },
    "options": {
        "fields": {
            "checkboxArrayEnum": {
                "label": "Checkbox Array Enum",
                "type": "checkbox", // <--- this makes each item in the array render as a checkbox
                "optionLabels": ["Option #1", "Option #2", "Option #3"]
            }
        }
    },
    "data": {
        "checkboxArrayEnum": ["option1", "option3"] // <--- this causes `option1` and `option3` to show as "checked" in the rendered form
    }
});

does that help at all? 🤔

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

2 participants