本文整理汇总了PHP中Nette\Forms\Form::getComponents方法的典型用法代码示例。如果您正苦于以下问题:PHP Form::getComponents方法的具体用法?PHP Form::getComponents怎么用?PHP Form::getComponents使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Nette\Forms\Form
的用法示例。
在下文中一共展示了Form::getComponents方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: enable
public function enable()
{
$this->validateScripts = array();
$this->toggleScript = '';
$this->central = TRUE;
foreach ($this->form->getControls() as $control) {
$script = $this->getValidateScript($control->getRules());
if ($script) {
$this->validateScripts[$control->getHtmlName()] = $script;
}
$this->toggleScript .= $this->getToggleScript($control->getRules());
if ($control instanceof ISubmitterControl && $control->getValidationScope() !== TRUE) {
$this->central = FALSE;
}
}
if ($this->validateScripts || $this->toggleScript) {
if ($this->central) {
$this->form->getElementPrototype()->onsubmit("return nette.validateForm(this)", TRUE);
} else {
foreach ($this->form->getComponents(TRUE, 'Nette\\Forms\\ISubmitterControl') as $control) {
if ($control->getValidationScope()) {
$control->getControlPrototype()->onclick("return nette.validateForm(this)", TRUE);
}
}
}
}
}
示例2: renderFormEnd
/**
* Renders form end.
*
* @return string
*/
public static function renderFormEnd(Form $form)
{
$s = '';
if (strcasecmp($form->getMethod(), 'get') === 0) {
$url = explode('?', $form->getElementPrototype()->action, 2);
if (isset($url[1])) {
foreach (preg_split('#[;&]#', $url[1]) as $param) {
$parts = explode('=', $param, 2);
$name = urldecode($parts[0]);
if (!isset($form[$name])) {
$s .= Nette\Utils\Html::el('input', array('type' => 'hidden', 'name' => $name, 'value' => urldecode($parts[1])));
}
}
}
}
foreach ($form->getComponents(true, 'Nette\\Forms\\Controls\\HiddenField') as $control) {
if (!$control->getOption('rendered')) {
$s .= $control->getControl();
}
}
if (iterator_count($form->getComponents(true, 'Nette\\Forms\\Controls\\TextInput')) < 2) {
$s .= '<!--[if IE]><input type=IEbug disabled style="display:none"><![endif]-->';
}
echo ($s ? "<div>{$s}</div>\n" : '') . $form->getElementPrototype()->endTag() . "\n";
}
示例3: renderFormEnd
/**
* Renders form end.
* @return string
*/
public static function renderFormEnd(Form $form, $withTags = TRUE)
{
$s = '';
if (strcasecmp($form->getMethod(), 'get') === 0) {
foreach (preg_split('#[;&]#', parse_url($form->getElementPrototype()->action, PHP_URL_QUERY), NULL, PREG_SPLIT_NO_EMPTY) as $param) {
$parts = explode('=', $param, 2);
$name = urldecode($parts[0]);
if (!isset($form[$name])) {
$s .= Html::el('input', ['type' => 'hidden', 'name' => $name, 'value' => urldecode($parts[1])]);
}
}
}
foreach ($form->getComponents(TRUE, Nette\Forms\Controls\HiddenField::class) as $control) {
if (!$control->getOption('rendered')) {
$s .= $control->getControl();
}
}
if (iterator_count($form->getComponents(TRUE, Nette\Forms\Controls\TextInput::class)) < 2) {
$s .= "<!--[if IE]><input type=IEbug disabled style=\"display:none\"><![endif]-->\n";
}
return $s . ($withTags ? $form->getElementPrototype()->endTag() . "\n" : '');
}
示例4: renderEnd
/**
* Renders form end.
* @return string
*/
public function renderEnd()
{
$s = '';
foreach ($this->form->getControls() as $control) {
if ($control instanceof Nette\Forms\Controls\HiddenField && !$control->getOption('rendered')) {
$s .= (string) $control->getControl();
}
}
if (iterator_count($this->form->getComponents(TRUE, 'Nette\\Forms\\Controls\\TextInput')) < 2) {
$s .= '<!--[if IE]><input type=IEbug disabled style="display:none"><![endif]-->';
}
if ($s) {
$s = $this->getWrapper('hidden container')->setHtml($s) . "\n";
}
return $s . $this->form->getElementPrototype()->endTag() . "\n";
}
示例5: save
/**
* @param Form
*/
public function save(Form $form)
{
$this->form = $form;
$this->entities = [];
$this->execute(function () {
$this->entityManager->persist($this->entity);
});
$this->saveValues($this->applyOffset($form->getComponents(), $this->offset), $this->entity);
if (!$form->isValid()) {
return;
}
$this->getExecutionStrategy()->confirm();
$valid = TRUE;
foreach ($this->entities as $entity) {
try {
$this->runValidation(function (ValidatorInterface $validator) use($entity) {
return $validator->validate($entity);
}, $form);
} catch (ValidationException $e) {
$valid = FALSE;
}
}
if ($valid && $this->getAutoFlush()) {
$this->flush();
}
}
示例6: applyCallbacksToButtons
/**
* @param Forms\Form $form
*/
private function applyCallbacksToButtons(Forms\Form $form)
{
/** @var SubmitButton $control */
foreach ($form->getComponents(FALSE, 'Nette\\Forms\\Controls\\SubmitButton') as $control) {
if (!in_array($control->getName(), array(self::FINISH_SUBMIT_NAME, self::NEXT_SUBMIT_NAME, self::PREV_SUBMIT_NAME))) {
continue;
}
$control->onClick[] = array($this, 'submitStep');
$control->onInvalidClick[] = array($this, 'submitStep');
if ($control->getName() === self::PREV_SUBMIT_NAME) {
$control->setValidationScope(FALSE);
}
}
}