Brandon Kelly

Apr  3, 2008

Sarge for ExpressionEngine

While working on the CMS for Navigant I had a need for adding <optgroup>s to a Drop-down List field. So I wrote this little extension that overrides ExpressionEngine’s built-in drop-down creation function. On top of <optgroup> support, you can also use it to specify each option’s value.

Sarge Field Settings

Installation Instructions

  1. Download the latest version (below)
  2. Upload ext.sarge.php to system/extensions/
  3. Enable Sarge in the Extensions Manager

Example Syntax

If you were to enter the following code into the Select Options text box in the Field Settings…

Select an Option =

[optgroup] = Fruit
    Apple = apl
    Orange = org
    Mango = mgo
[/optgroup]
[optgroup] = Veggies
    Bell Pepper = bpr
    Carrot = crt
    Potato = pto
[/optgroup]

…It would become what follows in the Publish form.

<option value="">Select an Option...</option>
<option value=""></option>
<optgroup label="Fruit">
    <option value="apl">Apple</option>
    <option value="org">Orange</option>
    <option value="mgo">Mango</option>
</optgroup>
<optgroup label="Veggies">
    <option value="bpr">Bell Pepper</option>
    <option value="crt">Carrot</option>
    <option value="pto">Potato</option>
</optgroup>

If you do not specify a value for an option, it will behave just like it would without this extension (the value would be set to the label).