本文整理汇总了PHP中Nette\Forms\Form::getGroups方法的典型用法代码示例。如果您正苦于以下问题:PHP Form::getGroups方法的具体用法?PHP Form::getGroups怎么用?PHP Form::getGroups使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Nette\Forms\Form
的用法示例。
在下文中一共展示了Form::getGroups方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getGroupsToRender
/**
* Determines which groups should be rendered (visual groups with at least one control).
*
* @return ControlGroup[]
*/
private function getGroupsToRender()
{
$groups = array_filter($this->form->getGroups(), function (ControlGroup $group) {
return $group->getControls() && $group->getOption('visual');
});
return $groups;
}
示例2: render
public function render(\Nette\Forms\Form $form, $mode = null)
{
$content = Html::el('div class="details"');
foreach ($form->getGroups() as $group) {
if (!$group->getControls() || !$group->getOption('visual')) {
continue;
}
$elgroup = $content->create('div class="viewGroup"');
$grouplabel = $group->getOption('label');
if (!is_string($grouplabel)) {
$grouplabel = $grouplabel->getText();
}
$elgroup->create('h5', $grouplabel);
$el = $elgroup->create('dl');
foreach ($group->getControls() as $control) {
if ($control instanceof \Nette\Forms\Controls\HiddenField || $control instanceof \Nette\Forms\Controls\Button) {
continue;
}
$label = $control->getLabel();
if (!is_string($label)) {
$label = $label->getText();
}
$el->create('dt', $label);
$value = $control->getValue();
if ($control instanceof \Nette\Forms\Controls\Checkbox) {
if ($value) {
$el->create('dd')->create('span class="yes"');
} else {
$el->create('dd')->create('span class="no"');
}
} elseif ($control instanceof \Nette\Forms\Controls\SelectBox) {
$items = FlatArray::getLeafs($control->getItems());
if (!isset($items[$value])) {
$el->create('dd class="na"', 'n/a');
continue;
}
$value = $items[$value];
if (!is_string($value)) {
$value = $value->getTitle();
}
$el->create('dd', $value);
} else {
if ($value instanceof \Nette\DateTime) {
$value = $value->format('j.n.Y');
}
if ($value !== '') {
$el->create('dd', $value);
} else {
$el->create('dd class="na"', 'n/a');
}
}
}
$elgroup->create('div style="{clear: both;}"');
}
return $content;
}
示例3: renderBody
/**
* Renders form body.
* @return string
*/
public function renderBody()
{
$s = $remains = '';
$defaultContainer = $this->getWrapper('group container');
$translator = $this->form->getTranslator();
foreach ($this->form->getGroups() as $group) {
if (!$group->getControls() || !$group->getOption('visual')) {
continue;
}
$container = $group->getOption('container', $defaultContainer);
$container = $container instanceof Html ? clone $container : Html::el($container);
$id = $group->getOption('id');
if ($id) {
$container->id = $id;
}
$s .= "\n" . $container->startTag();
$text = $group->getOption('label');
if ($text instanceof Html) {
$s .= $this->getWrapper('group label')->add($text);
} elseif (is_string($text)) {
if ($translator !== NULL) {
$text = $translator->translate($text);
}
$s .= "\n" . $this->getWrapper('group label')->setText($text) . "\n";
}
$text = $group->getOption('description');
if ($text instanceof Html) {
$s .= $text;
} elseif (is_string($text)) {
if ($translator !== NULL) {
$text = $translator->translate($text);
}
$s .= $this->getWrapper('group description')->setText($text) . "\n";
}
$s .= $this->renderControls($group);
$remains = $container->endTag() . "\n" . $remains;
if (!$group->getOption('embedNext')) {
$s .= $remains;
$remains = '';
}
}
$s .= $remains . $this->renderControls($this->form);
$container = $this->getWrapper('form container');
$container->setHtml($s);
return $container->render(0);
}
示例4: render
public function render(\Nette\Forms\Form $form, $mode = null)
{
$content = Html::el('form')->action($form->action)->method($form->method);
foreach ($form->getGroups() as $group) {
if (!$group->getControls() || !$group->getOption('visual')) {
continue;
}
$elgroup = $content->create('fieldset');
$grouplabel = $group->getOption('label');
if (!is_string($grouplabel)) {
$grouplabel = $grouplabel->getText();
}
$elgroup->create('legend', $grouplabel);
$el = $elgroup->create('dl');
foreach ($group->getControls() as $control) {
if ($control instanceof \Nette\Forms\Controls\HiddenField) {
$el->add($control->getControl());
continue;
}
if ($control instanceof \Nette\Forms\Controls\Button) {
$el->create('dt')->id($control->htmlId . '-dt');
$el->create('dd')->id($control->htmlId . '-dd')->add($control->getControl());
continue;
}
$label = $control->getLabel();
$el->create('dt')->id($control->htmlId . '-dt')->add($label);
$dd = $el->create('dd')->id($control->htmlId . '-dd');
$dd->add($control->getControl());
if ($control->hasErrors()) {
$dd->class('error');
$errors = $control->getErrors();
$dd->create('span class="error"');
$dd->create('', $control->errors[0]);
}
}
$elgroup->create('div style="{clear: both;}"');
}
return $content;
}