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

How To selected setData element select multiple #1543

Open
Fharhanamrin opened this issue Mar 18, 2024 · 1 comment
Open

How To selected setData element select multiple #1543

Fharhanamrin opened this issue Mar 18, 2024 · 1 comment

Comments

@Fharhanamrin
Copy link

Description:

Environment Details:

  • formBuilder Version:
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.7.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jqueryui/1.13.2/jquery-ui.min.js"></script>
<script src="https://formbuilder.online/assets/js/form-builder.min.js"></script>
  • Browser:
    Crome
  • OS:
    Mac/unix

Expected Behavior

Actual Behavior

Steps to Reproduce

Screenshot - (optional)

image

I have saved the data, but when I edit it it doesn't select the last one I saved?

@lucasnetau
Copy link
Collaborator

lucasnetau commented Mar 18, 2024

Please provide a reproducible script. formBuilder options array and the formData you are passing to setData at a minimum.

Restoring multiple select controls is passing tests.

image

For example:

const options = {
        typeUserAttrs: {
            "*": {
                testSingleSelectAttribute: {
                    label: 'Single Select', // i18n support by passing and array eg. ['optionCount', {count: 3}]
                    multiple: false, // optional, omitting generates normal <select>
                    options: {
                        'incorrect green': 'Incorrect',
                        'correct blue': 'Correct',
                        'incorrect red': 'Incorrect'
                    },
                    style: 'border: 1px solid red',
                    value: 'incorrect green',
                },
                testMultipleSelectAttribute: {
                    label: 'Multiple Select', // i18n support by passing and array eg. ['optionCount', {count: 3}]
                    multiple: true, // optional, omitting generates normal <select>
                    options: {
                        'incorrect green': 'Incorrect',
                        'correct blue': 'Correct',
                        'correct red': 'Correct'
                    },
                    style: 'border: 1px solid red',
                    value: ['incorrect green'],
                }
            }
        },
        formData: [],
        i18n: {
            location: "https://raw.githubusercontent.com/kevinchappell/formBuilder-languages/master/",
        },
    }
const formData = [
        {
            "type": "text",
            "required": false,
            "className": "form-control",
            "name": "text-1709526699751-0",
            "testSingleSelectAttribute": 'correct blue',
            "testMultipleSelectAttribute":  ['correct red','correct blue']
        }
]

gave me this correct result

image

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