Dropdown Select2 and new or empty value

QuestionsDropdown Select2 and new or empty value
mofel asked 4 years ago


Is there any way, with a dropdown field to allow adding new value or leave empty value
(a little bit more as an autocomplete but with the select2 design) ?


3 Answers
Abu Ghufran answered 4 years ago

You can have empty value in list by prepending ":;"

$col["editoptions"] = array("value"=>":;".$str);

To allow addition is currently not supported.

mofel answered 3 years ago

Hello Abu,

I'm back on this old question because i still have this problem 🙂

Empty value doesn't seem to work with select2 integration (i tried on your demo code)

$col["editoptions"] = array("value"=>":;".$str);

I have a blank line in normal select but not select2.

Do i make something wrong ?


Abu Ghufran answered 3 years ago

For select2, you must specify some placeholder text. e.g. '-'
$col["editoptions"] = array("value"=>":-;".$str);

Your Answer

9 + 7 =

Login with your Social Id:

OR, enter

Attach code here and paste link in question.
Attach screenshot here and paste link in question.

How useful was this discussion?

Click on a star to rate it!

Average rating 0 / 5. Vote count: 0

No votes so far! Be the first to rate it.

We are sorry that this post was not useful for you!

Let us improve this post!

Tell us how we can improve this post?