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


PHP Form::getComponents方法代碼示例

本文整理匯總了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);
                 }
             }
         }
     }
 }
開發者ID:vrana,項目名稱:ORM-benchmark,代碼行數:27,代碼來源:InstantClientScript.php

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

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

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

示例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();
     }
 }
開發者ID:librette,項目名稱:doctrine-forms,代碼行數:29,代碼來源:Mapper.php

示例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);
         }
     }
 }
開發者ID:webchemistry,項目名稱:forms-wizard,代碼行數:17,代碼來源:Wizard.php


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