本文整理汇总了PHP中Nette\Application\UI\Form::getComponents方法的典型用法代码示例。如果您正苦于以下问题:PHP Form::getComponents方法的具体用法?PHP Form::getComponents怎么用?PHP Form::getComponents使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Nette\Application\UI\Form
的用法示例。
在下文中一共展示了Form::getComponents方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setEntityToForm
/**
* @param BaseEntity $entity
* @param Form $form
*/
public function setEntityToForm(BaseEntity &$entity, Form &$form)
{
/** @var BaseControl $control */
foreach ($form->getComponents() as $control) {
/** @noinspection PhpParamsInspection */
$value = $this->getEntityValue($entity, $control);
if (!$value) {
continue;
}
// do base
$this->mapValueToForm($value, $control);
}
}
示例2: createComponentPostForm
protected function createComponentPostForm()
{
$form = new Form();
$form->addText('title', 'Titulek:')->setRequired();
$form->addTextArea('content', 'Obsah:', 55, 8)->setRequired()->setAttribute('class', 'mceEditor');
$form->getElementPrototype()->onsubmit('tinyMCE.triggerSave()');
$form->addSubmit('send', 'Vložit článek');
foreach ($form->getComponents(TRUE, 'SubmitButton') as $button) {
if (!$button->getValidationScope()) {
continue;
}
$button->getControlPrototype()->onclick('tinyMCE.triggerSave()');
}
// setup form rendering
$renderer = $form->getRenderer();
$renderer->wrappers['controls']['container'] = NULL;
$renderer->wrappers['pair']['container'] = 'div class="form-group text-center"';
$renderer->wrappers['pair']['.error'] = 'has-error';
$renderer->wrappers['control']['container'] = 'div class="col-sm-10"';
$renderer->wrappers['label']['container'] = 'div class="control-label text-center col-sm-1"';
$renderer->wrappers['control']['description'] = 'span class=help-block';
$renderer->wrappers['control']['errorcontainer'] = 'span class=help-block';
// make form and controls compatible with Twitter Bootstrap
$form->getElementPrototype()->class('form-horizontal');
foreach ($form->getControls() as $control) {
if ($control instanceof Controls\Button) {
$control->getControlPrototype()->addClass(empty($usedPrimary) ? 'btn btn-primary' : 'btn btn-default');
$usedPrimary = TRUE;
} elseif ($control instanceof Controls\TextBase || $control instanceof Controls\SelectBox || $control instanceof Controls\MultiSelectBox) {
$control->getControlPrototype()->addClass('form-control');
} elseif ($control instanceof Controls\Checkbox || $control instanceof Controls\CheckboxList || $control instanceof Controls\RadioList) {
$control->getSeparatorPrototype()->setName('div')->addClass($control->getControlPrototype()->type);
}
}
$form->onSuccess[] = array($this, 'postFormSucceeded');
return $form;
}