Skip to content

Instantly share code, notes, and snippets.

@estefanionsantos
Last active September 8, 2021 00:48
Show Gist options
  • Save estefanionsantos/5d494031fc861d6491bc665a1ac44103 to your computer and use it in GitHub Desktop.
Save estefanionsantos/5d494031fc861d6491bc665a1ac44103 to your computer and use it in GitHub Desktop.
group form rubricate
<?php
use Rubricate\Form\SelectOptForm;
use Rubricate\Form\SelectOptGroupForm;
$opt['lorem'] = array(1 => 'ipsum', 2 => 'dolor', 3 => 'amet');
$opt['aliquam'] = array(4 => 'tincidunt', 5 => 'ligula', 6 => 'nulla');
$select = new SelectOptGroupForm('latim', $opt);
/*
// OR 3 arguments 'selected'
$select = new SelectOptGroupForm('latim', $opt, 2);
*/
$select->setAttribute('class', 'selectpicker');
echo $select->getElement();
/*
<select name="latim" class="selectpicker">
<optgroup label="lorem">
<option value="1">ipsum</option>
<option value="2">dolor</option>
<option value="3">amet</option>
</optgroup>
<optgroup label="aliquam">
<option value="4">tincidunt</option>
<option value="5">ligula</option>
<option value="6">nulla</option>
</optgroup>
</select>
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment