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


PHP Form::isRoot方法代碼示例

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


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

示例1: getFormErrorMessages

 private function getFormErrorMessages(Form $form)
 {
     $errors = [];
     foreach ($form->getErrors() as $key => $error) {
         if ($form->isRoot()) {
             $errors['#root'][] = $error->getMessage();
         } else {
             $errors[] = $error->getMessage();
         }
     }
     foreach ($form->all() as $child) {
         if (!$child->isValid()) {
             $errors[$child->getName()] = $this->getFormErrorMessages($child);
         }
     }
     return $errors;
 }
開發者ID:Kid-Binary,項目名稱:Boilerplate,代碼行數:17,代碼來源:FormErrorsTrait.php

示例2: getErrorMessages

 private function getErrorMessages(\Symfony\Component\Form\Form $form)
 {
     $errors = array();
     foreach ($form->getErrors() as $key => $error) {
         if ($form->isRoot()) {
             $errors['#'][] = $error->getMessage();
         } else {
             $errors[] = $error->getMessage();
         }
     }
     foreach ($form->all() as $child) {
         if (!$child->isValid()) {
             $errors[$child->getName()] = $this->getErrorMessages($child);
         }
     }
     return $errors;
 }
開發者ID:AndriusRimkus,項目名稱:LinkShare,代碼行數:17,代碼來源:DefaultController.php

示例3: getErrorMessages

 /**
  * This method comes from Flip's answer on Stackoverflow:
  * http://stackoverflow.com/a/17428869/731138
  *
  * @param Form $form
  * @return array
  */
 protected function getErrorMessages(Form $form)
 {
     $errors = array();
     foreach ($form->getErrors() as $error) {
         if ($form->isRoot()) {
             $errors['#'][] = $error->getMessage();
         } else {
             $errors[] = $error->getMessage();
         }
     }
     foreach ($form->all() as $child) {
         if (!$child->isValid()) {
             $errors[$child->getName()] = $this->getErrorMessages($child);
         }
     }
     return $errors;
 }
開發者ID:enumag,項目名稱:symfony-collection,代碼行數:24,代碼來源:BaseController.php

示例4: getErrorMessages

 /**
  * @param Form $form
  * @return array
  */
 protected function getErrorMessages(Form $form)
 {
     $errors = [];
     foreach ($form->getErrors() as $key => $error) {
         if ($form->isRoot()) {
             $errors[] = $this->toErrorArray($error);
         } else {
             $errors[] = $this->toErrorArray($error, $form);
         }
     }
     foreach ($form->all() as $child) {
         if (!$child->isValid()) {
             foreach ($this->getErrorMessages($child) as $error) {
                 $errors[] = $error;
             }
         }
     }
     return $errors;
 }
開發者ID:EdgarPost,項目名稱:symfony-rest-api-bundle,代碼行數:23,代碼來源:FormValidationException.php

示例5: getFormErrorMessagesWithLabels

 public function getFormErrorMessagesWithLabels(Form $form, FormHelper $formHelper)
 {
     $errors = array();
     foreach ($form->getErrors() as $key => $error) {
         if ($form->isRoot()) {
             $errors['#'][] = $error->getMessage();
         } else {
             $errors[] = $error->getMessage();
         }
     }
     foreach ($form->all() as $child) {
         if (!$child->isValid()) {
             $label = $child->getConfig()->getOption('label');
             if (!$label) {
                 $label = $formHelper->humanize($child->getName());
             }
             $errors[$label] = $this->getFormErrorMessagesWithLabels($child, $formHelper);
         }
     }
     return $errors;
 }
開發者ID:victormacko,項目名稱:symfony-smarty-standalone-forms,代碼行數:21,代碼來源:FormErrorsTrait.php

示例6: getErrorMessages

 public static function getErrorMessages(\Symfony\Component\Form\Form $form)
 {
     $errors = array();
     foreach ($form->getErrors() as $key => $error) {
         if ($form->isRoot()) {
             $errors['#'][] = $error->getMessage();
         } else {
             $errors[] = $error->getMessage();
         }
     }
     foreach ($form->all() as $child) {
         if (!$child->isValid()) {
             $err = self::getErrorMessages($child);
             if (!empty($err)) {
                 $errors[$child->getName()] = $err;
             }
         }
     }
     $checkError = current($errors);
     if (!empty($checkError)) {
         return $errors;
     } else {
         return;
     }
 }
開發者ID:rYsvelain,項目名稱:FunkylabBundle,代碼行數:25,代碼來源:BaseController.php

示例7: getFormErrors

 /**
  * Dado un formulario se devuelven sus errores parseados
  * @param Form $form
  * @param bool $deep option for Form getErrors method
  * @param bool $flatten option for Form getErrors method
  * @return array
  */
 public function getFormErrors(Form $form, $deep = false, $flatten = true)
 {
     // Se parsean los errores que existan en el formulario para devolverlos en el reponse
     $errors = array();
     //Se parsean los posibles errores generales del formulario(incluyendo los asserts a nivel de entidad)
     foreach ($form->getErrors($deep, $flatten) as $key => $error) {
         if ($form->isRoot()) {
             $errors['form'][] = $error->getMessage();
         } else {
             $errors[] = $error->getMessage();
         }
     }
     $childs = $form->getIterator();
     //Se parsean los posibles errores de cada campo del formulario
     /** @var Form $child */
     foreach ($childs as $child) {
         $fieldErrors = $child->getErrors();
         while ($fieldErrors->current() != null) {
             $errors[$child->getName()][] = $fieldErrors->current()->getMessage();
             $fieldErrors->next();
         }
     }
     return $errors;
 }
開發者ID:sopinet,項目名稱:apihelper-bundle,代碼行數:31,代碼來源:ApiHelper.php


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