当前位置: 首页>>代码示例>>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;未经允许,请勿转载。