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


PHP FormBuilderInterface::getType方法代碼示例

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


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

示例1: buildForm

 /**
  * Adds a CSRF field to the form when the CSRF protection is enabled.
  *
  * @param FormBuilderInterface $builder The form builder
  * @param array                $options The options
  */
 public function buildForm(FormBuilderInterface $builder, array $options)
 {
     if (!$options['csrf_protection']) {
         return;
     }
     $builder->addEventSubscriber(new CsrfValidationListener($options['csrf_field_name'], $options['csrf_token_manager'], $options['csrf_token_id'] ?: ($builder->getName() ?: get_class($builder->getType()->getInnerType())), $options['csrf_message'], $this->translator, $this->translationDomain));
 }
開發者ID:Kyra2778,項目名稱:AMR,代碼行數:13,代碼來源:FormTypeCsrfExtension.php

示例2: buildForm

 /**
  * Adds a CSRF field to the form when the CSRF protection is enabled.
  *
  * @param FormBuilderInterface $builder The form builder
  * @param array                $options The options
  */
 public function buildForm(FormBuilderInterface $builder, array $options)
 {
     if (!$options['csrf_protection']) {
         return;
     }
     $builder->setAttribute('csrf_factory', $builder->getFormFactory())->addEventSubscriber(new CsrfValidationListener($options['csrf_field_name'], $options['csrf_provider'], $options['intention'] ?: ($builder->getName() ?: get_class($builder->getType()->getInnerType()))));
 }
開發者ID:senthil-r-wiredelta,項目名稱:meilleure-visite,代碼行數:13,代碼來源:FormTypeCsrfExtension.php

示例3: buildForm

 public function buildForm(FormBuilderInterface $builder, array $options)
 {
     // Creatd with createNamed('', ...) so likely an API request, might
     // need to make this a little better in the future
     $buildTabs = $builder->getName() === '' ? false : $options['build_tabs'];
     $tabsData = $options['tabs_data'];
     $formType = $builder->getType()->getInnerType();
     $tabDefaults = ['inherit_data' => true];
     foreach ($tabsData as $name => $data) {
         $tabOptions = array_merge($tabDefaults, $data);
         $forceTab = isset($data['force_tab']) ? $data['force_tab'] : false;
         // Remove unused option
         if ($forceTab) {
             unset($tabOptions['force_tab']);
         }
         // Build Tab
         if ($buildTabs || $forceTab) {
             $parent = $builder->create($name, 'tab', $tabOptions);
             $builder->add($parent);
             // Just add it to the main form
         } else {
             $parent = $builder;
         }
         // Get method name
         $method = sprintf('build%sForm', ucfirst($name));
         if (!method_exists($formType, $method)) {
             throw new \InvalidArgumentException(sprintf('Method "%s" does not exist in "%s"', $method, get_class($formType)));
         }
         // call buildTabNameForm
         call_user_func([$formType, $method], $parent, $options, $builder->getData());
     }
 }
開發者ID:symedit,項目名稱:symedit,代碼行數:32,代碼來源:FlattenTabExtension.php

示例4: getTypes

 /**
  * @param \Symfony\Component\Form\FormBuilderInterface $formBuilder
  *
  * @return array
  */
 protected function getTypes(FormBuilderInterface $formBuilder)
 {
     $types = array();
     for ($type = $formBuilder->getType(); null !== $type; $type = $type->getParent()) {
         array_unshift($types, $type->getInnerType());
     }
     return $types;
 }
開發者ID:manudatta12,項目名稱:POC,代碼行數:13,代碼來源:FormTypeFieldExtension.php

示例5: assertFormType

 /**
  * Assert that the form element has an inner type of type $typeClass and
  * the specified options with their values.
  *
  * @param FormBuilderInterface $element
  * @param string               $typeClass FQN class
  * @param array                $options   keys are option names, values the
  *                                        expected option values
  */
 private function assertFormType(FormBuilderInterface $element, $typeClass, array $options)
 {
     $type = $element->getType()->getInnerType();
     $this->assertInstanceOf($typeClass, $type);
     foreach ($options as $option => $expected) {
         $this->assertEquals($expected, $element->getOption($option), "Option '{$option}' does not have the expected value '" . serialize($expected) . "'");
     }
 }
開發者ID:pkdevbox,項目名稱:DoctrinePHPCRBundle,代碼行數:17,代碼來源:PHPCRTypeGuesserTest.php


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