Search code examples
drop-down-menuexpressionenginemulti-select

ExpressionEngine, Create a front-end dropdown list from backend Multi Select custom field


Evening all,

I have a Multi-Select custom field in my ExpressionEngine backend which I need to create a drop-down list from in my EE site. I can't think of a way but I'm sure it can't be too difficult. Can anyone explain how to do this please? (Preferably without the purchase of a plugin etc..)

Many thanks in advance


Solution

  • If you're using EE2 and the native Multi-Select Field custom channel field, this code will output all selected options from your multi-select custom field:

    <select>
        {exp:channel:entries channel="channel_name" limit="1" dynamic="off"}
            {custom_field_name}
                <option value="{item}">{item}</option>
            {/custom_field_name}
        {/exp:channel:entries}
    </select>
    

    The syntax for outputting the contents of a Multi-Select custom field in EE2 is slightly different from EE1. Instead of using {option} to output the value, it's been replaced with {item}.

    Also of interest is that the native, "built-in" Multi-Select custom field in EE2 can't output an option and value separately.

    You can use the P&T Field Pack to restore the EE1 FF Multi-select functionality where a Multi-Select custom field can have a value and an option.