當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。