I want a please select text in an empty enum selection field

Hi, I think I'm not the first one looking for this, but couldn't find anything on the forum. What I need is an enum selection widget where the empty field is filled with the text: "Please select".
3 answers

You can accomplish this with a JS snippet inside the form that contains the select box (HTML / JavaScript Snippet in the App store) :

setTimeout(function () {
    $.each($('select'), function () {
        $(this).find('option:first-child').text('Please change me');
}, 1000);

This executes after 1 second (1000 milliseconds), finds all of the select boxes on the page and changes there first option value to the one provided in the text method ('Please change me'). It's not guaranteed to work if the form takes a longer than the timeout period to load, but it could be further improved to work no matter when the form loads by providing a condition which executes the code until a select box is found and changed.

Here's an improved version in vanilla (pure) JS (should work in IE8). It is going to run until it finds enough select elements on the page (indicated by howManySelectsOnThePage). I do not recommend this approach for multilingual applications.

var changeSelects = function () {
    setTimeout(function () {
        var howManySelectsOnThePage = 10;
        var selects = document.getElementsByTagName('select');
        if (selects.length <= howManySelectsOnThePage) {
        } else {
            for (var i = 0; i < selects.length; i++) {
                try {
                    selects[i].options[0].text = 'Please Change me';
                } catch (e) {}
    }, 250);



I don't think it is possible to replace the empty select option with a text. What you could do is add a enumeration option with this text and set it as default in your entity attribute.

Validate the attribute if you don't want the "please select" option as a valid option.

Maybe it's also an option to use a non-persistent list as a datasource.


You can make a picture of the text 'please select here' and use it with then enum toggle widget (appstore). Map the empty value to the 'please select' picture and all other values to an empty picture (or leave them out and make default picture an empty picture). Style the enum toggle close to the enum dropdown.

It it not exactly what you want, but comes close:) The alternative is a custom widget.