Editor select option class?

Editor select option class?

janosijanosi Posts: 7Questions: 4Answers: 0
edited April 2016 in Editor

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

Answers

  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    Answer ✓

    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 use field().input() to get the select element and then add the classes to its option elements as required.

    Allan

This discussion has been closed.