How to update the options of a select list?

How to update the options of a select list?

nsaknsak Posts: 36Questions: 6Answers: 0

hi,

when updating the options of a select list, according to the data of a table in my database, I need the first option to be a message, something like "Please select one of the following". So, I tried this:

...    
{
            "label": "list",
            "name": "tableID.list",
            "type": "select",
            "ipOpts": [
                {
                    "label": "Please select",
                    "value": 0
                }
            ]
        }
...

and then,

editor.field( 'tableID.list' ).update( ... );

But it doesn't seem to make any difference, meaning that I still see only the options that come from the database. Is there a way I can do it?

Thanks!!!

Answers

  • allanallan Posts: 63,523Questions: 1Answers: 10,473 Site admin

    The update() method will completely replace the list of options available, so you would need to also include the "Please select" in that list.

    Allan

This discussion has been closed.