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


PHP Form::getControls方法代碼示例

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


在下文中一共展示了Form::getControls方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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);
                 }
             }
         }
     }
 }
開發者ID:vrana,項目名稱:ORM-benchmark,代碼行數:27,代碼來源:InstantClientScript.php

示例2: 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

示例3: 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

示例4: findErrors

 /**
  * @return array
  */
 public function findErrors()
 {
     $formErrors = method_exists($this->form, 'getAllErrors') ? $this->form->getErrors() : $this->form->getErrors();
     if (!$formErrors) {
         return array();
     }
     $form = $this->form;
     $translate = function ($errors) use($form) {
         if ($translator = $form->getTranslator()) {
             // If we have translator, translate!
             foreach ($errors as $key => $val) {
                 $errors[$key] = $translator->translate($val);
             }
         }
         return $errors;
     };
     if (!$this->errorsAtInputs) {
         return $translate($formErrors);
     }
     if (method_exists($this->form, 'getAllErrors')) {
         return $translate($this->form->getErrors());
     }
     foreach ($this->form->getControls() as $control) {
         /** @var \Nette\Forms\Controls\BaseControl $control */
         if (!$control->hasErrors()) {
             continue;
         }
         $formErrors = array_diff($formErrors, $control->getErrors());
     }
     return $translate($formErrors);
 }
開發者ID:TomHetmer,項目名稱:logs-db,代碼行數:34,代碼來源:BootstrapRenderer.php

示例5: findFormControls

 /**
  * @return array
  */
 public function findFormControls()
 {
     $controls = iterator_to_array($this->form->getControls());
     return array_filter($controls, function (Controls\BaseControl $control) {
         return !$control->getOption('rendered');
     });
 }
開發者ID:rostenkowski,項目名稱:nette-forms-renderer,代碼行數:10,代碼來源:BootstrapRenderer.php

示例6: renderBody

 public function renderBody()
 {
     $this->assertInForm();
     $groups = $this->renderGroups();
     $groupless = $this->renderPairs($this->form->getControls());
     return $this->areGroupsRenderedFirst() ? $groups . "\n" . $groupless : $groupless . "\n" . $groups;
 }
開發者ID:instante,項目名稱:bootstrap3renderer,代碼行數:7,代碼來源: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: ApplyBootstrapToControls

 /**
  * @param Form $form
  */
 public static function ApplyBootstrapToControls(Form $form)
 {
     $usedPrimary = FALSE;
     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);
         }
     }
 }
開發者ID:pipaslot,項目名稱:forms,代碼行數:17,代碼來源:BootstrapHelper.php

示例9: findFields

 /**
  * Find specific controls within the current form
  *
  * @param string $fieldtype
  * @param bool   $skipRendered false if you want to get even the rendered ones
  * @return array
  *
  * @internal
  */
 public function findFields($fieldtype, $skipRendered = TRUE)
 {
     $stack = array();
     $fieldtype = $fieldtype;
     foreach ($this->form->getControls() as $control) {
         if ($skipRendered && $control->getOption('rendered', FALSE)) {
             continue;
         }
         if ($control->getOption('blockname') === $fieldtype) {
             $stack[] = $control;
         }
     }
     return $stack;
 }
開發者ID:valicek1,項目名稱:nestraps,代碼行數:23,代碼來源:Nestraps.php

示例10: renderFormBegin

 /**
  * Renders form begin.
  * @return string
  */
 public static function renderFormBegin(Form $form, array $attrs, $withTags = TRUE)
 {
     foreach ($form->getControls() as $control) {
         $control->setOption('rendered', FALSE);
     }
     $el = $form->getElementPrototype();
     $el->action = (string) $el->action;
     $el = clone $el;
     if (strcasecmp($form->getMethod(), 'get') === 0) {
         $el->action = preg_replace('~\\?[^#]*~', '', $el->action, 1);
     }
     $el->addAttributes($attrs);
     return $withTags ? $el->startTag() : $el->attributes();
 }
開發者ID:richard-ejem,項目名稱:forms,代碼行數:18,代碼來源:Runtime.php

示例11: render

 /**
  * @param \Nette\Forms\Form $form
  * @param string|null $mode
  * @return string
  */
 public function render(Nette\Forms\Form $form, $mode = null)
 {
     $form->getElementPrototype()->class[] = 'form-horizontal';
     foreach ($form->getControls() as $control) {
         if ($control instanceof Controls\Button) {
             $control->setAttribute('class', empty($usedPrimary) ? 'btn btn-primary' : 'btn btn-default');
             $usedPrimary = true;
         } elseif ($control instanceof Controls\TextBase || $control instanceof Controls\SelectBox || $control instanceof Controls\MultiSelectBox) {
             $control->setAttribute('class', 'form-control');
         } elseif ($control instanceof Controls\Checkbox || $control instanceof Controls\CheckboxList || $control instanceof Controls\RadioList) {
             $control->getSeparatorPrototype()->setName('div')->class($control->getControlPrototype()->type);
         }
     }
     return parent::render($form, $mode);
 }
開發者ID:venne,項目名稱:venne,代碼行數:20,代碼來源:Bootstrap3Renderer.php

示例12: render

 public function render(Forms\Form $form, $mode = NULL)
 {
     $form->getElementPrototype()->class('form-horizontal')->novalidate(TRUE);
     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:milo,項目名稱:web-project,代碼行數:15,代碼來源:BootstrapRenderer.php

示例13: 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

示例14: render

 /**
  * Provides complete form rendering.
  * @param  Nette\Forms\Form
  * @param  string 'begin', 'errors', 'ownerrors', 'body', 'end' or empty to render all
  * @return string
  */
 public function render(Nette\Forms\Form $form, $mode = null)
 {
     $form->getElementPrototype()->addClass('form-inline');
     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:jaromir92,項目名稱:Sportwin,代碼行數:23,代碼來源:BootstrapInlineRenderer.php

示例15: 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


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