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

select value is not selected for select input #6

Open
desaiuditd opened this issue Nov 2, 2017 · 0 comments
Open

select value is not selected for select input #6

desaiuditd opened this issue Nov 2, 2017 · 0 comments

Comments

@desaiuditd
Copy link

For the following code, I'm not able to get the selected=selected attribute for the valid <option> tag in select input of the form.

Can someone help me?

const formAttr = {
    method: 'POST',
    action: '/api/admin/model/client/'
};
const formData = {
    'user': '59fae7403de42b36749a9c82'
};
const form = Form.create(formAttr, formData);
const users = {
    '58cd87da1b2d7d1e4563e1ca': '[email protected]',
    '59fae7403de42b36749a9c82': '[email protected]'
}

form.select()
    .attr({
        name: 'user',
        class: 'form-control',
    })
    .setOptions(users)
    .setEmpty('Select User')
    .render();

Output

<select name="user" class="form-control">
    <option value>Select User</option>
    <option value="58cd87da1b2d7d1e4563e1ca">undefined</option>
    <option value="59fae7403de42b36749a9c82">[email protected]</option>
</select>
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