How set atributte on individual option of select
Notice: This thread is very old.
- alnux
- Member | 139
Hi again,
My questions is how can i set attribute with Form:setAttribute() method an option of select box
the next html code is generate by
$form->addSelect('parent_id', 'Recurso Padre:', $recursos, 15)->setAttribute('class', 'form-control');
<select name="parent_id" size="15" class="form-control" id="frm-crearEditar-parent_id">
<option value="0"></option>
<option value="1">Permiso Acl</option>
<option value="2">-- Sub de Acl Permiso</option>
<option value="3">---- Sub de sub de Acl Permiso</option>
<option value="4"> Acl Permiso 2</option>
<option value="5" selected>-- Sub de Acl Permiso2</option>
<option value="10">---- Nuevo recurso</option>
</select>
is there any way to add a " disabled " attribute to an option tag from Present class??
<option value="3" disabled >---- Sub de sub de Acl Permiso</option>
thanks
Last edited by alnux (2014-05-30 19:28)
- alnux
- Member | 139
I found a solution and share you
$arr = array(
'item' => Nette\Utils\Html::el('option')->value('item')->setHtml('popisek'),
'item2' => Nette\Utils\Html::el('option')->value('item2')->setHtml('popisek')->disabled(TRUE),
);
$form->addSelect('select', 'select', $arr)
// případně
$form['select']->setItems($arr);
thanks to Aurielle from link