当前位置: 首页>>代码示例>>PHP>>正文


PHP Form::count方法代码示例

本文整理汇总了PHP中Symfony\Component\Form\Form::count方法的典型用法代码示例。如果您正苦于以下问题:PHP Form::count方法的具体用法?PHP Form::count怎么用?PHP Form::count使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Symfony\Component\Form\Form的用法示例。


在下文中一共展示了Form::count方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: getFormErrorMessages

 public function getFormErrorMessages(\Symfony\Component\Form\Form $form)
 {
     $errors = array();
     $formErrors = iterator_to_array($form->getErrors(false, true));
     foreach ($formErrors as $key => $error) {
         $template = $error->getMessageTemplate();
         $parameters = $error->getMessageParameters();
         foreach ($parameters as $var => $value) {
             $template = str_replace($var, $value, $template);
         }
         $errors[$key] = $template;
     }
     if ($form->count()) {
         foreach ($form as $child) {
             if (!$child->isValid()) {
                 $errors[$child->getName()] = $this->getFormErrorMessages($child);
             }
         }
     }
     return $errors;
 }
开发者ID:elom5000,项目名称:BardisCMS,代码行数:21,代码来源:Helpers.php

示例2: getFormErrors

 public function getFormErrors(\Symfony\Component\Form\Form $form)
 {
     $errors = array();
     if ($form->count() > 0) {
         foreach ($form->all() as $child) {
             /**
              * @var \Symfony\Component\Form\Form $child
              */
             if (!$child->isValid()) {
                 $errors[$child->getName()] = $this->getFormErrors($child);
             }
         }
     } else {
         /**
          * @var \Symfony\Component\Form\FormError $error
          */
         foreach ($form->getErrors() as $key => $error) {
             $errors[] = $error->getMessage();
         }
     }
     return $errors;
 }
开发者ID:MaximePlancke,项目名称:Freedom,代码行数:22,代码来源:UtilitiesApiHelper.php

示例3: getErrorMessages

 private function getErrorMessages(Form $form)
 {
     $errors = array();
     foreach ($form->getErrors() as $key => $error) {
         $template = $error->getMessageTemplate();
         $parameters = $error->getMessageParameters();
         foreach ($parameters as $var => $value) {
             $template = str_replace($var, $value, $template);
         }
         $errors[$key] = $template;
     }
     if ($form->count()) {
         foreach ($form as $child) {
             if (!$child->isValid()) {
                 $errors[$child->getName()] = $this->getErrorMessages($child);
             }
         }
     }
     return $errors;
 }
开发者ID:claroline,项目名称:distribution,代码行数:20,代码来源:WebsiteOptionsManager.php

示例4: getErrorMessages

 /**
  * Collects error messages from a symfony form object
  *
  * @param  \Symfony\Component\Form\Form $form
  * @return array                        An array containing form error messages
  */
 public static function getErrorMessages(\Symfony\Component\Form\Form $form, $i = null)
 {
     $errors = array();
     if (null === $i) {
         $i = 0;
     }
     foreach ($form->getErrors() as $error) {
         $template = $error->getMessageTemplate();
         $parameters = $error->getMessageParameters();
         foreach ($parameters as $var => $value) {
             $template = str_replace($var, $value, $template);
         }
         $errors[$i] = $template;
         $i++;
     }
     if ($form->count()) {
         foreach ($form as $child) {
             if (!$child->isValid()) {
                 $errors = array_merge($errors, self::getErrorMessages($child, $i));
             }
         }
     }
     return $errors;
 }
开发者ID:hkmshb,项目名称:OpitHrm,代码行数:30,代码来源:Utils.php

示例5: getErrorMessages

 /**
  * Generate a simpler validation error structure.
  * 
  * @param \Symfony\Component\Form\Form $form
  * @return type
  */
 private function getErrorMessages(\Symfony\Component\Form\Form $form)
 {
     $errors = array();
     foreach ($form->getErrors() as $key => $error) {
         $errors[$key] = $error->getMessage();
     }
     if ($form->count()) {
         foreach ($form->all() as $child) {
             if (!$child->isValid()) {
                 $errors[$child->getName()] = $this->getErrorMessages($child);
             }
         }
     }
     return $errors;
 }
开发者ID:onema,项目名称:base-api-bundle,代码行数:21,代码来源:BaseApiController.php


注:本文中的Symfony\Component\Form\Form::count方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。