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

Placeholder on multiple: false fields is not shown #37

Open
lkacenja opened this issue Jun 23, 2016 · 1 comment
Open

Placeholder on multiple: false fields is not shown #37

lkacenja opened this issue Jun 23, 2016 · 1 comment

Comments

@lkacenja
Copy link

lkacenja commented Jun 23, 2016

Thanks for the component. I could be completely missing something obvious here. In case someone else ran into this, I wanted to document a solution. It is a fairly documented case that select2 requires an empty <option> for placeholders to show up on single value fields. This seems to still be the case. I was able to get the placeholder to show up by adding an empty option to the data prop. Something like:

var data = [];
var empty = {id: null, text: null};
data.unshift(empty);
@cooperka
Copy link

This is a few years old now and the suggested workaround did not work for me: the empty option was ignored and not rendered.

I ended up using allowClear: true with an onUnselect callback.

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