當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Form::getElementPrototype方法代碼示例

本文整理匯總了PHP中Nette\Forms\Form::getElementPrototype方法的典型用法代碼示例。如果您正苦於以下問題:PHP Form::getElementPrototype方法的具體用法?PHP Form::getElementPrototype怎麽用?PHP Form::getElementPrototype使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Nette\Forms\Form的用法示例。


在下文中一共展示了Form::getElementPrototype方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: 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";
 }
開發者ID:TheTypoMaster,項目名稱:SPHERE-Framework,代碼行數:30,代碼來源:FormMacros.php

示例2: decorateFormControls

 private function decorateFormControls()
 {
     $this->form->getElementPrototype()->class('form-horizontal');
     $this->usedPrimary = FALSE;
     foreach ($this->form->getControls() as $control) {
         if ($control instanceof NetteBaseControl) {
             $this->decorateFormControl($control);
         }
     }
 }
開發者ID:achse,項目名稱:bootstrap3-form-decorator,代碼行數:10,代碼來源:Bootstrap3FormDecorator.php

示例3: render

 /**
  * Render the templates
  *
  * @param \Nette\Forms\Form $form
  * @param string $mode
  *
  * @return void
  */
 public function render(Nette\Forms\Form $form, $mode = NULL)
 {
     if ($this->form !== $form) {
         $this->form = $form;
         // translators
         if ($translator = $this->form->getTranslator()) {
             $this->template->setTranslator($translator);
         }
         // controls placeholders & classes
         foreach ($this->form->getControls() as $control) {
             $this->prepareControl($control);
         }
         $formEl = $form->getElementPrototype();
         if (!$formEl->class || stripos('form-', (string) $formEl->class) === FALSE) {
             $formEl->addClass('form-horizontal');
         }
     }
     $this->template->form = $this->form;
     $this->template->_form = $this->form;
     $this->template->renderer = $this;
     if ($mode === NULL) {
         $this->template->render();
     } elseif ($mode === 'begin') {
         FormMacros::renderFormBegin($this->form, array());
     } elseif ($mode === 'end') {
         FormMacros::renderFormEnd($this->form);
     } else {
         $this->template->setFile(__DIR__ . '/@parts.latte');
         $this->template->mode = $mode;
         $this->template->render();
         $this->template->setFile(__DIR__ . '/@form.latte');
     }
 }
開發者ID:rostenkowski,項目名稱:FormsBootstrapRendererExtension,代碼行數:41,代碼來源:BootstrapRenderer.php

示例4: getToggleScript

 private function getToggleScript(Rules $rules, $cond = NULL)
 {
     $s = '';
     foreach ($rules->getToggles() as $id => $visible) {
         $s .= "visible = true; {$cond}\n" . "nette.toggle(" . Nette\Json::encode((string) $id) . ", " . ($visible ? '' : '!') . "visible);\n";
     }
     $formName = Nette\Json::encode((string) $this->form->getElementPrototype()->id);
     foreach ($rules as $rule) {
         if ($rule->type === Rule::CONDITION && is_string($rule->operation)) {
             $script = $this->getClientScript($rule->control, $rule->operation, $rule->arg);
             if ($script) {
                 $res = $this->getToggleScript($rule->subRules, $cond . "{$script} visible = visible && " . ($rule->isNegative ? '!' : '') . "res;\n");
                 if ($res) {
                     $el = $rule->control->getControlPrototype();
                     if ($el->getName() === 'select') {
                         $el->onchange("nette.forms[{$formName}].toggle(this)", TRUE);
                     } else {
                         $el->onclick("nette.forms[{$formName}].toggle(this)", TRUE);
                         //$el->onkeyup("nette.forms[$formName].toggle(this)", TRUE);
                     }
                     $s .= $res;
                 }
             }
         }
     }
     return $s;
 }
開發者ID:vrana,項目名稱:ORM-benchmark,代碼行數:27,代碼來源:InstantClientScript.php

示例5: render

 /**
  * Render the templates.
  * @param Form    $form
  * @param string  $mode
  * @param array   $args
  */
 public function render(Form $form, $mode = NULL, $args = NULL)
 {
     if ($this->template === NULL) {
         if ($presenter = $form->lookup('Nette\\Application\\UI\\Presenter', FALSE)) {
             /** @var \Nette\Application\UI\Presenter $presenter */
             $this->template = clone $presenter->getTemplate();
         } else {
             $this->template = new FileTemplate();
             $this->template->registerFilter(new \Nette\Latte\Engine());
         }
     }
     if ($this->form !== $form) {
         $this->form = $form;
         // translators
         if ($translator = $this->form->getTranslator()) {
             $this->template->setTranslator($translator);
         }
         // controls placeholders & classes
         foreach ($this->form->getControls() as $control) {
             $this->prepareControl($control);
         }
         $formEl = $form->getElementPrototype();
         if (!($classes = self::getClasses($formEl)) || stripos($classes, 'form-') === FALSE) {
             //$formEl->addClass('form-horizontal');
         }
     } elseif ($mode === 'begin') {
         foreach ($this->form->getControls() as $control) {
             /** @var \Nette\Forms\Controls\BaseControl $control */
             $control->setOption('rendered', FALSE);
         }
     }
     $this->template->setFile(__DIR__ . '/@form.latte');
     $this->template->setParameters(array_fill_keys(array('control', '_control', 'presenter', '_presenter'), NULL) + array('_form' => $this->form, 'form' => $this->form, 'renderer' => $this));
     if ($mode === NULL) {
         if ($args) {
             $this->form->getElementPrototype()->addAttributes($args);
         }
         $this->template->render();
     } elseif ($mode === 'begin') {
         FormMacros::renderFormBegin($this->form, (array) $args);
     } elseif ($mode === 'end') {
         FormMacros::renderFormEnd($this->form);
     } else {
         $attrs = array('input' => array(), 'label' => array());
         foreach ((array) $args as $key => $val) {
             if (stripos($key, 'input-') === 0) {
                 $attrs['input'][substr($key, 6)] = $val;
             } elseif (stripos($key, 'label-') === 0) {
                 $attrs['label'][substr($key, 6)] = $val;
             }
         }
         $this->template->setFile(__DIR__ . '/@parts.latte');
         $this->template->mode = $mode;
         $this->template->attrs = (array) $attrs;
         $this->template->render();
     }
 }
開發者ID:josefzajac,項目名稱:BootstrapFormRenderer,代碼行數:63,代碼來源:BootstrapRenderer.php

示例6: render

 /**
  * @param Nette\Forms\Form $form
  * @param null             $mode
  *
  * @return mixed
  */
 public function render(Nette\Forms\Form $form, $mode = null)
 {
     $form->getElementPrototype()->addClass('form-horizontal');
     $form->getElementPrototype()->setNovalidate('novalidate');
     foreach ($form->getControls() as $control) {
         if ($control instanceof Controls\Button) {
             if (strpos($control->getControlPrototype()->getClass(), 'btn') === FALSE) {
                 $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);
         }
     }
     return parent::render($form, $mode);
 }
開發者ID:krausv,項目名稱:forms-bootstrap,代碼行數:24,代碼來源:BootstrapRenderer.php

示例7: renderEnd

 /**
  * Renders form end.
  * @return string
  */
 public function renderEnd()
 {
     $s = '';
     foreach ($this->form->getControls() as $control) {
         if ($control instanceof HiddenField && !$control->getOption('rendered')) {
             $s .= (string) $control->getControl();
         }
     }
     if ($s) {
         $s = $this->getWrapper('hidden container')->setHtml($s) . "\n";
     }
     return $s . $this->form->getElementPrototype()->endTag() . "\n";
 }
開發者ID:jakubkulhan,項目名稱:nette,代碼行數:17,代碼來源:ConventionalRenderer.php

示例8: 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->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" : '');
 }
開發者ID:MartinSadovy,項目名稱:forms,代碼行數:26,代碼來源:Runtime.php

示例9: 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";
 }
開發者ID:svobodni,項目名稱:web,代碼行數:20,代碼來源:DefaultFormRenderer.php

示例10: render

 public function render(\Nette\Forms\Form $form, $mode = null)
 {
     $this->wrappers['controls']['container'] = 'div class=col-sm-12';
     $this->wrappers['pair']['container'] = 'div class=form-group';
     $this->wrappers['control']['container'] = 'div class=col-lg-8';
     $this->wrappers['label']['container'] = 'label class=col-lg-4';
     // 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);
         }
     }
     return parent::render($form, $mode);
 }
開發者ID:04EO,項目名稱:hup-nette,代碼行數:20,代碼來源:YetiRenderer.php

示例11: render

 /**
  * Render the templates
  *
  * @param \Nette\Forms\Form $form
  *
  * @return void
  */
 public function render(Nette\Forms\Form $form)
 {
     if ($this->form !== $form) {
         $this->form = $form;
         // translators
         if ($translator = $this->form->getTranslator()) {
             $this->template->setTranslator($translator);
         }
         // controls placeholders & classes
         foreach ($this->form->getControls() as $control) {
             $this->prepareControl($control);
         }
         $formEl = $form->getElementPrototype();
         if (stripos('form-', $formEl->class) === FALSE) {
             $formEl->addClass('form-horizontal');
         }
     }
     $this->template->form = $this->form;
     $this->template->renderer = $this;
     $this->template->render();
 }
開發者ID:rostenkowski,項目名稱:nette-forms-renderer,代碼行數:28,代碼來源:BootstrapRenderer.php

示例12: prepareForm

 /**
  * Make form and controls compatible with Twitter Bootstrap
  * @param Form $form
  */
 protected function prepareForm(Form $form)
 {
     $form->getElementPrototype()->class[] = 'form-horizontal';
     $translator = $form->getTranslator();
     foreach ($form->controls as $control) {
         /** @var BaseControl $control */
         if ($control instanceof HiddenField) {
             continue;
         } elseif ($control instanceof Button) {
             $control->controlPrototype->class[] = "btn-block btn-lg";
         } else {
             if ($control->getLabel()) {
                 $control->setAttribute('placeholder', $control->caption);
                 if (empty($control->controlPrototype->attrs['title'])) {
                     $control->setAttribute('title', $translator ? $translator->translate($control->caption) : $control->caption);
                 }
                 $control->getLabelPrototype()->attrs["style"] = "display:none";
             }
         }
     }
     BootstrapHelper::ApplyBootstrapToControls($form);
 }
開發者ID:pipaslot,項目名稱:forms,代碼行數:26,代碼來源:Bootstrap3StackRenderer.php

示例13: 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);
         }
     }
 }
開發者ID:norik16,項目名稱:TripMap,代碼行數:24,代碼來源:Helpers.php

示例14: addFormModeClass

 private function addFormModeClass(Form $form, array &$attrs)
 {
     if ($this->renderMode !== RenderModeEnum::VERTICAL) {
         if (isset($attrs['class'])) {
             $classes = explode(' ', $attrs['class']);
             $pos = array_search('no-' . $this->renderMode, $classes, TRUE);
             if ($pos !== FALSE) {
                 // if .no-form-<mode> class is present, remove it and not include form-<mode> class
                 unset($classes[$pos]);
             } else {
                 // otherwise add form-<mode> class
                 $classes[] = $this->renderMode;
             }
             if (count($classes) === 0) {
                 unset($attrs['class']);
             } else {
                 $attrs['class'] = implode(' ', $classes);
             }
         } else {
             $classes = $form->getElementPrototype()->getAttribute('class');
             if (is_string($classes)) {
                 $classes = explode(' ', $classes);
             } elseif (!is_array($classes)) {
                 $classes = [];
             }
             $classes[] = $this->renderMode;
             $attrs['class'] = implode(' ', $classes);
         }
     }
 }
開發者ID:instante,項目名稱:bootstrap3renderer,代碼行數:30,代碼來源:BootstrapRenderer.php

示例15: prepareForm

 /**
  * Make form and controls compatible with Twitter Bootstrap
  * @param Form $form
  */
 protected function prepareForm(Form $form)
 {
     $form->getElementPrototype()->class[] = 'form-inline';
     BootstrapHelper::ApplyBootstrapToControls($form);
 }
開發者ID:pipaslot,項目名稱:forms,代碼行數:9,代碼來源:Bootstrap3InlineRenderer.php


注:本文中的Nette\Forms\Form::getElementPrototype方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。