public getControl ( ) : Nette\Utils\Html | ||
리턴 | Nette\Utils\Html |
public function getControl()
{
$input = parent::getControl();
$items = $this->getItems();
$ids = [];
if ($this->generateId) {
foreach ($items as $value => $label) {
$ids[$value] = $input->id . '-' . $value;
}
}
return $this->container->setHtml(Nette\Forms\Helpers::createInputList($this->translate($items), array_merge($input->attrs, ['id:' => $ids, 'checked?' => $this->value, 'disabled:' => $this->disabled, 'data-nette-rules:' => [key($items) => $input->attrs['data-nette-rules']]]), ['for:' => $ids] + $this->itemLabel->attrs, $this->separator));
}
/** * @internal * @param \Nette\Forms\Controls\RadioList $control * @return bool */ public static function getRadioListItems(Controls\RadioList $control) { $items = array(); foreach ($control->items as $key => $value) { $el = $control->getControl($key); if ($el->getName() === 'input') { $items[$key] = $radio = (object) array('input' => $el, 'label' => $cap = $control->getLabel(NULL, $key), 'caption' => $cap->getText()); } else { $items[$key] = $radio = (object) array('input' => $el[0], 'label' => $el[1], 'caption' => $el[1]->getText()); } $radio->label->addClass('radio'); $radio->html = clone $radio->label; $radio->html->insert(0, $radio->input); } return $items; }