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


PHP FormInterface::count方法代碼示例

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


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

示例1: buildViewRootForm

 /**
  * @test
  */
 public function buildViewRootForm()
 {
     $this->configureFormRoot();
     $this->form->count()->shouldBeCalled()->willReturn(2);
     $extension = $this->createExtension();
     $this->buildView($extension);
     $attributes = $this->view->vars['attr'];
     $this->assertArrayHasKey('novalidate', $attributes);
     $this->assertTrue($attributes['novalidate']);
     $this->assertArrayHasKey('data-parsley-validate', $attributes);
     $this->assertTrue($attributes['data-parsley-validate']);
     $this->assertArrayNotHasKey('data-parsley-trigger', $attributes);
 }
開發者ID:J-Ben87,項目名稱:ParsleyBundle,代碼行數:16,代碼來源:ParsleyTypeExtensionTest.php

示例2: buildView

 /**
  * {@inheritdoc}
  *
  * @param FormView      $view
  * @param FormInterface $form
  * @param array         $options
  */
 public function buildView(FormView $view, FormInterface $form, array $options)
 {
     if ($form->count() == 0) {
         return;
     }
     array_map(array($this, 'validateButton'), $form->all());
 }
開發者ID:pr0coder,項目名稱:Inkstand,代碼行數:14,代碼來源:FormActionsType.php

示例3: getErrorMessages

 /**
  * Returns an array with form fields errors
  *
  * @param FormInterface $form
  * @param bool|false $useLabels
  * @param array $errors
  * @return array
  */
 public function getErrorMessages(FormInterface $form, $useLabels = false, $errors = array())
 {
     if ($form->count() > 0) {
         foreach ($form->all() as $child) {
             if (!$child->isValid()) {
                 $errors = $this->getErrorMessages($child, $useLabels, $errors);
             }
         }
     }
     foreach ($form->getErrors() as $error) {
         if ($useLabels) {
             $fieldNameData = $this->getErrorFormLabel($form);
         } else {
             $fieldNameData = $this->getErrorFormId($form);
         }
         $fieldName = $fieldNameData;
         if ($useLabels) {
             /**
              * @ignore
              */
             $fieldName = $this->translator->trans($fieldNameData['label'], array(), $fieldNameData['domain']);
         }
         $errors[$fieldName] = $error->getMessage();
     }
     return $errors;
 }
開發者ID:auamarto,項目名稱:crud-bundle,代碼行數:34,代碼來源:FormErrorHandler.php

示例4: isExpanded

 protected function isExpanded(FormInterface $form)
 {
     if (0 === $form->count()) {
         return false;
     }
     $innerType = $form->getConfig()->getType()->getInnerType();
     if (0 === strpos(get_class($innerType), 'Symfony')) {
         return false;
     }
     return true;
 }
開發者ID:HNKSoftware,項目名稱:FrameworkBundle,代碼行數:11,代碼來源:FormRenderHelper.php

示例5: unbind

 /**
  * Returns the form's data like $form->submit() expects it
  *
  * @param FormInterface $form
  * @return array
  */
 protected function unbind(FormInterface $form)
 {
     if ($form->count() > 0) {
         $ary = array();
         foreach ($form->all() as $name => $child) {
             $value = $this->unbind($child);
             if (null !== $value || (is_array($value) || $value instanceof Collection) && count($value) > 0) {
                 $ary[$name] = $value;
             }
         }
         return $ary;
     } else {
         $data = $form->getViewData();
         return $data instanceof Collection ? $data->toArray() : $data;
     }
 }
開發者ID:noglitchyo,項目名稱:pim-community-dev,代碼行數:22,代碼來源:PatchSubscriber.php

示例6: addChildErrors

 private static function addChildErrors(FormInterface $parent, &$errors, $path = '')
 {
     if ($parent->count() == 0) {
         return;
     }
     foreach ($parent as $child) {
         if ($path == '') {
             $childPath = $child->getName();
         } else {
             $childPath = $path . '.' . $child->getName();
         }
         if ($child->isValid()) {
             continue;
         }
         $childErrors = array();
         foreach ($child->getErrors() as $key => $error) {
             $childErrors[$key] = $error->getMessage();
         }
         if (count($childErrors) > 0) {
             $errors[$childPath] = $childErrors;
         }
         self::addChildErrors($child, $errors, $childPath);
     }
 }
開發者ID:proyecto404,項目名稱:UtilBundle,代碼行數:24,代碼來源:FormUtil.php


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