本文整理汇总了PHP中Nette\Forms\Form::getRenderer方法的典型用法代码示例。如果您正苦于以下问题:PHP Form::getRenderer方法的具体用法?PHP Form::getRenderer怎么用?PHP Form::getRenderer使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Nette\Forms\Form
的用法示例。
在下文中一共展示了Form::getRenderer方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setupRenderersLayout
private function setupRenderersLayout()
{
$renderer = $this->form->getRenderer();
if ($renderer instanceof DefaultFormRenderer) {
$renderer->wrappers['controls']['container'] = NULL;
$renderer->wrappers['pair']['container'] = 'div class=form-group';
$renderer->wrappers['pair']['.error'] = 'has-error';
$renderer->wrappers['control']['container'] = 'div class=col-sm-9';
$renderer->wrappers['label']['container'] = 'div class="col-sm-3 control-label"';
$renderer->wrappers['control']['description'] = 'span class=help-block';
$renderer->wrappers['control']['errorcontainer'] = 'span class=help-block';
}
}
示例2: renderFormBegin
/**
* Renders form begin.
* @param Form $form
* @param array $attrs
* @param bool $withTags
* @return string
*/
public static function renderFormBegin(Form $form, array $attrs, $withTags = TRUE)
{
$renderer = $form->getRenderer();
if ($renderer instanceof IManualRenderer) {
$renderer->beforeRender($form);
}
return parent::renderFormBegin($form, $attrs, $withTags);
}
示例3: unsubscriptionForm
/**
* Front-end unsubscription form
*
* @return Nette\Forms\Form
*/
public static function unsubscriptionForm($widget = FALSE, $widgetId = '')
{
$form = new Form('unsubscriptionFront' . $widgetId);
$form->addText('email', 'Your e-mail address')->setRequired('To unsubscribe, you need to fill in your e-mail address.')->addRule(Form::EMAIL, 'Your e-mail address must be valid.');
$form->addSubmit('submit', 'Unsubscribe')->setAttribute('class', 'subscribeButton');
// swap renderer for widgets
if ($widget == TRUE) {
$renderer = $form->getRenderer();
$renderer->wrappers['controls']['container'] = 'dl';
$renderer->wrappers['pair']['container'] = NULL;
$renderer->wrappers['label']['container'] = 'dt';
$renderer->wrappers['control']['container'] = 'dd';
}
return $form;
}
示例4: bootstrapForm
public static function bootstrapForm(Form $form)
{
// setup form rendering
$renderer = $form->getRenderer();
$renderer->wrappers['controls']['container'] = NULL;
$renderer->wrappers['pair']['container'] = 'div class="form-group"';
$renderer->wrappers['pair']['.error'] = 'has-error';
$renderer->wrappers['control']['container'] = 'div class="col-sm-9"';
$renderer->wrappers['label']['container'] = 'div class="col-sm-3 control-label"';
$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-shadow' : 'btn btn-default');
$usedPrimary = TRUE;
} elseif ($control instanceof Controls\TextBase || $control instanceof Controls\SelectBox || $control instanceof Controls\MultiSelectBox) {
$control->getControlPrototype()->addClass('form-control form-control-shadow');
} elseif ($control instanceof Controls\Checkbox || $control instanceof Controls\CheckboxList || $control instanceof Controls\RadioList) {
$control->getSeparatorPrototype()->setName('div')->addClass($control->getControlPrototype()->type);
}
}
}
示例5: array
<?php
/**
* Nette\Forms custom rendering example.
*/
require_once __DIR__ . '/../../Nette/loader.php';
use Nette\Forms\Form, Nette\Debug, Nette\Web\Html;
Debug::enable();
$countries = array('Select your country', 'Europe' => array('CZ' => 'Czech Republic', 'SK' => 'Slovakia', 'GB' => 'United Kingdom'), 'CA' => 'Canada', 'US' => 'United States', '?' => 'other');
$sex = array('m' => Html::el('option', 'male')->style('color: #248bd3'), 'f' => Html::el('option', 'female')->style('color: #e948d4'));
// Step 1: Define form with validation rules
$form = new Form();
// setup custom rendering
$renderer = $form->getRenderer();
$renderer->wrappers['form']['container'] = Html::el('div')->id('form');
$renderer->wrappers['form']['errors'] = FALSE;
$renderer->wrappers['group']['container'] = NULL;
$renderer->wrappers['group']['label'] = 'h3';
$renderer->wrappers['pair']['container'] = NULL;
$renderer->wrappers['controls']['container'] = 'dl';
$renderer->wrappers['control']['container'] = 'dd';
$renderer->wrappers['control']['.odd'] = 'odd';
$renderer->wrappers['control']['errors'] = TRUE;
$renderer->wrappers['label']['container'] = 'dt';
$renderer->wrappers['label']['suffix'] = ':';
$renderer->wrappers['control']['requiredsuffix'] = " •";
// group Personal data
$form->addGroup('Personal data');
$form->addText('name', 'Your name')->addRule(Form::FILLED, 'Enter your name');
$form->addText('age', 'Your age')->addRule(Form::FILLED, 'Enter your age')->addRule(Form::INTEGER, 'Age must be numeric value')->addRule(Form::RANGE, 'Age must be in range from %d to %d', array(10, 100));
$form->addSelect('gender', 'Your gender', $sex);
示例6: renderFormBegin
/**
* @param Form $form
* @param array $args
*/
private static function renderFormBegin(Form $form, array $args)
{
if ($form->getRenderer() instanceof BootstrapRenderer) {
$form->render('begin', $args);
} else {
Nette\Bridges\FormsLatte\FormMacros::renderFormBegin($form, $args);
}
}