} /** * @param string $name * @param string $caption * @return Controls\ResetButton */ public function addReset($name, $caption = NULL) { return $this[$name] = new Controls\ResetButton($caption); } } // radio list helper RadioList::extensionMethod('getItemsOuterLabel', function (RadioList $_this) { $items = []; foreach ($_this->items as $key => $value) { $html = $_this->getControl($key); $html[1]->addClass('radio'); $items[$key] = $html[1]->add($html[0]); // control } return $items; }); // radio list helper RadioList::extensionMethod('getFirstItemLabel', function (RadioList $_this) { $items = $_this->items; $first = key($items); $html = $_this->getControl($first); $html[1]->addClass('control-label'); $html[1]->setText($_this->caption); return $html[1]; });
/** * @internal * @param \Nette\Forms\Controls\RadioList $control * @return bool */ public static function getRadioListItems(Controls\RadioList $control) { $items = array(); if (count($control->items) === 0) { $control->getControl(); //sets rendered flag to control if emtpy } foreach ($control->items as $key => $value) { $el = $control->getControlPart($key); if ($el->getName() === 'input') { $items[$key] = $radio = (object) array('input' => $el, 'label' => $cap = $control->getLabelPart($key), 'caption' => $cap->getText()); } else { $items[$key] = $radio = (object) array('input' => $el[0], 'label' => $el[1], 'caption' => $el[1]->getText()); } $radio->html = clone $radio->label; $radio->html->insert(0, $radio->input); } return $items; }
/** * @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->getControlPart($key); if ($el->getName() === 'input') { $items[$key] = $radio = (object) array('input' => $el, 'label' => $cap = $control->getLabelPart($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; $display = $control->getOption('display', 'inline'); if ($display == 'inline') { $radio->html->addClass($display); } $radio->html->insert(0, $radio->input); } return $items; }
/** * * @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); $el[1]->addClass('radio'); $items[$key] = $radio = (object) array('input' => $el[0], 'label' => $el[1], 'caption' => $el[1]->getText()); $radio->html = clone $radio->label; $radio->html->insert(0, $radio->input); } return $items; }