disable (or add class) to a checkbox within a checkboxlist

3 years ago

mikeb
Member | 30
+
+1
-

I can see how to disable (or style) one option from a select list from this thread.

But i can't see how to disable (or style, or add a class) to one particular checkbox within a checkbox list.

I can make the label of just one checkbox in a list and style that:

$form->addCheckboxList($a_field, $label);
$c = $form ->getComponent ($a_field);

$el=\Nette\Utils\Html::el('span')->setHtml($option['label']);
$el->style['color'] = 'green';
$arr[$option['value']] = $el;
//...
$c->setItems($arr);

and i add a class to all the checkboxes in checkboxlist:

$c->getControlPrototype()->setAttribute('class', 'my-class-for-all');

but not just one of the checkbox inputs. getComponent() does not work on the individual checkboxes in the list.
any idea how I can grab/style/add attributes to just one?
i can't even see how to set the defaults of a checkboxlist

thanks