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