Editor select option class?
Editor select option class?
Hello
Is there an option to assign a different class to every option in a select?
For example this is how I set values of the select now:
{
'name': 'field_id',
'type': 'select',
'label': 'Select one',
'options': [{
"value": "32",
"label": "32"
}, {
"value": "31",
"label": "31"
}]
}
This is what I had in mind:
{
'name': 'field_id',
'type': 'select',
'label': 'Select one',
'options': [{
"class": "first class",
"value": "32",
"label": "32"
}, {
"class": "second class",
"value": "31",
"label": "31"
}]
}
In which case, the <option> tag should contain the class provided.
Edited by Allan - Syntax highlighting. Details on how to highlight code using markdown can be found in this guide.
This question has an accepted answers - jump to answer
This discussion has been closed.
Answers
There currently isn't a built in way to apply a class name to the
option
elements in the select list I'm afraid. You'd need to usefield().input()
to get theselect
element and then add the classes to itsoption
elements as required.Allan