Page 1 of 1

dropdowns with optgroup

Posted: Fri Aug 03, 2007 3:16 pm
by gardnern
Would be great if the dropdown functions (CreateInputDropdown, ect) had the option of using .

I would suggest doing this by the way you pass an array to the function. Right now, it takes a single dimension array

Code: Select all

array(
 [0] => Item One
 [1] => Item Two
)
It could check if its a multideminisonal array, and if so create opt groups...

Code: Select all

array(
 ['Group One'] => array(
   [0] => Item One
   [1] => Item Two
 )
 ['Group Two'] => array(
   [2] => Item Three
   [3] => Item Four
 )
)
which would generate...

Code: Select all

<select>
 <optgroup label="Group One">
  <option value="0">Item One</option>
  <option value="1">Item Two</option>
 </optgroup>
 <optgroup label="Group Two">
  <option value="2">Item Three</option>
  <option value="3">Item Four</option>
 </optgroup>
</select>