本文整理匯總了PHP中Nette\Forms\Form::isMethod方法的典型用法代碼示例。如果您正苦於以下問題:PHP Form::isMethod方法的具體用法?PHP Form::isMethod怎麽用?PHP Form::isMethod使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Nette\Forms\Form
的用法示例。
在下文中一共展示了Form::isMethod方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: renderFormEnd
/**
* Renders form end.
* @return string
*/
public static function renderFormEnd(Form $form, $withTags = TRUE)
{
$s = '';
if ($form->isMethod('get')) {
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->getControls() as $control) {
if ($control->getOption('type') === 'hidden' && !$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" : '');
}
示例2: renderBegin
/**
* Renders form begin.
* @return string
*/
public function renderBegin()
{
$this->counter = 0;
foreach ($this->form->getControls() as $control) {
$control->setOption('rendered', FALSE);
}
if ($this->form->isMethod('get')) {
$el = clone $this->form->getElementPrototype();
$query = parse_url($el->action, PHP_URL_QUERY);
$el->action = str_replace("?{$query}", '', $el->action);
$s = '';
foreach (preg_split('#[;&]#', $query, NULL, PREG_SPLIT_NO_EMPTY) as $param) {
$parts = explode('=', $param, 2);
$name = urldecode($parts[0]);
if (!isset($this->form[$name])) {
$s .= Html::el('input', ['type' => 'hidden', 'name' => $name, 'value' => urldecode($parts[1])]);
}
}
return $el->startTag() . ($s ? "\n\t" . $this->getWrapper('hidden container')->setHtml($s) : '');
} else {
return $this->form->getElementPrototype()->startTag();
}
}