Solved thread

This post is marked as solved. If you think the information contained on this thread must be part of the official documentation, please contribute submitting a pull request to its repository.

Optgroup in Forms/Element/Select

Hey, how should I add optgroup to Select tag for Forms? I'd like to create something like this:

<optgroup label="Alaskan/Hawaiian Time Zone">
    <option value="AK">Alaska</option>
    <option value="HI">Hawaii</option>
</optgroup>

Many thanks for the prompt reply!



552
Accepted
answer
edited Sep '14

Hello Sir,

you can add optgroups in your form via:

<?php
// ...
$this->add(new Select("status", array(
     "Active" => array('A1' => 'A One', 'A2' => 'A Two'), // "Active" = OptGroupTitle
     "B" => "B One"
)));

source: https://github.com/phalcon/cphalcon/pull/1463



1.8k

Thanks, works perfectly :)