As far as I can see the existing placeholder for select2 field is hard coded to the a string, "- Select -" or "- None -".
If you want to change that placeholder text there is no way of accomplish that as it is now.

CommentFileSizeAuthor
#2 use-field-placeholder-3002216-2.patch613 bytesmiax

Comments

MickeA created an issue. See original summary.

miax’s picture

StatusFileSize
new613 bytes

Attached patch adds a check for the $element[‘#placeholder’] and uses that if it exist.
This way you can override the default placeholder text with code.

chr.fritsch’s picture

You could already set

$my_select2_form_element['#select2']['placeholder'] = 'My better placeholder';

It's possible to overwrite all select2 properties in that way.

We could also make the placeholder configurable over the UI. I think that is possible for the core autocomplete widget as well.

chr.fritsch’s picture

@MickeA Does it work for you, or is something else needed?

miax’s picture

Status: Active » Closed (works as designed)

Hi, Thanks for the info!
I realize I did not test the existing functionality well enough before submitting this issue. Sorry for that.
Marking this as "Works as designed".

Thanks // M