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


PHP FormBuilder::getData方法代码示例

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


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

示例1:

 function it_builds_form_with_proper_fields(FormBuilder $builder, ZoneInterface $zone)
 {
     $builder->getData()->willReturn($zone);
     $zone->getType()->shouldBeCalled();
     $builder->add('name', 'text', Argument::any())->shouldBeCalled()->willReturn($builder);
     $builder->addEventSubscriber(Argument::type(AddCodeFormSubscriber::class))->shouldBeCalled()->willReturn($builder);
     $builder->add('type', 'sylius_zone_type_choice', Argument::any())->shouldBeCalled()->willReturn($builder);
     $builder->add('scope', 'choice', Argument::any())->shouldBeCalled()->willReturn($builder);
     $builder->add('members', 'collection', Argument::any())->shouldBeCalled()->willReturn($builder);
     $this->buildForm($builder, []);
 }
开发者ID:ahmadrabie,项目名称:Sylius,代码行数:11,代码来源:ZoneTypeSpec.php

示例2: buildForm

 /**
  * {@inheritDoc}
  */
 public function buildForm(FormBuilder $builder, array $options)
 {
     $admin = $this->getAdmin($options);
     if ($options['delete'] && $admin->isGranted('DELETE')) {
         $builder->add('_delete', 'checkbox', array('required' => false, 'property_path' => false));
     }
     if (!$admin->hasSubject()) {
         $admin->setSubject($builder->getData());
     }
     $admin->defineFormBuilder($builder);
     $builder->prependClientTransformer(new ArrayToModelTransformer($admin->getModelManager(), $admin->getClass()));
 }
开发者ID:ratasxy,项目名称:SonataAdminBundle,代码行数:15,代码来源:AdminType.php

示例3: buildForm

 public function buildForm(FormBuilder $builder, array $options)
 {
     $data = $builder->getData();
     $builder->add('code', 'text', array('required' => false, 'label' => 'systemevents.code'))->add('description', 'textarea', array('required' => false, 'label' => 'systemevents.description'))->add('bundle', 'choice', array('empty_data' => $data->getBundle(), 'empty_value' => $data->getBundle(), 'choices' => $this->provider->getActiveBundleList(), 'multiple' => false, 'required' => false, 'label' => 'systemevents.bundle'))->add('entity', 'choice', array('empty_data' => $data->getEntity(), 'empty_value' => $data->getEntity(), 'choices' => array($data->getEntity()), 'multiple' => false, 'required' => false, 'label' => 'systemevents.entity'))->add('type', 'choice', array('choices' => SystemEvents::getTypeTypes(), 'multiple' => false, 'empty_data' => null, 'required' => false, 'label' => 'systemevents.type'))->add('actions', 'choice', array('choices' => SystemEvents::getActionsTypes(), 'multiple' => true, 'empty_data' => null, 'expanded' => true, 'required' => false, 'label' => ' '))->add('ownerType', 'hidden', array('required' => false, 'label' => 'systemevents.ownertype'))->add('ownerId', 'hidden', array('required' => false, 'label' => 'systemevents.ownerid'))->add('users', 'referencelist', array('columns' => array('username', 'firstName', 'lastName'), 'columnsType' => array('string', 'string', 'string'), 'label' => 'unit.users', 'entityName' => 'LowbiSystemBundle:User', 'actions' => array('select' => true, 'remove' => true), 'searchForm' => 'Lowbi\\SystemBundle\\Form\\UserSearchType'))->add('message', 'textarea', array('required' => false, 'label' => 'systemevents.message'))->add('redirectUrl', 'text', array('required' => false, 'label' => 'systemevents.redirecturl'));
 }
开发者ID:r4cker,项目名称:lowbi,代码行数:5,代码来源:SystemEventsTab1Type.php

示例4: addField

 /**
  * Add a new field type into the provided FormBuilder
  *
  * @param \Symfony\Component\Form\FormBuilder $formBuilder
  * @param \Sonata\AdminBundle\Admin\FieldDescriptionInterface $fieldDescription
  * @return void
  */
 public function addField(FormBuilder $formBuilder, FieldDescriptionInterface $fieldDescription)
 {
     // There is a bug in the GraphWalker, so for now we always load related associations
     // for more information : https://github.com/symfony/symfony/pull/1056
     if ($formBuilder->getData() && in_array($fieldDescription->getType(), array(ClassMetadataInfo::ONE_TO_MANY, ClassMetadataInfo::MANY_TO_MANY, ClassMetadataInfo::MANY_TO_ONE, ClassMetadataInfo::ONE_TO_ONE))) {
         $value = $fieldDescription->getValue($formBuilder->getData());
         $infos = $fieldDescription->getAssociationMapping();
         if ($value instanceof $infos['targetEntity'] && $value instanceof \Doctrine\ORM\Proxy\Proxy) {
             $relatedId = 'get' . current($fieldDescription->getAdmin()->getModelManager()->getIdentifierFieldNames($infos['targetEntity']));
             $value->{$relatedId}();
             // force to load the lazy loading method __load in the proxy methode
         }
     }
     switch ($fieldDescription->getType()) {
         case ClassMetadataInfo::ONE_TO_MANY:
             $this->getOneToManyField($formBuilder, $fieldDescription);
             break;
         case ClassMetadataInfo::MANY_TO_MANY:
             $this->defineManyToManyField($formBuilder, $fieldDescription);
             break;
         case ClassMetadataInfo::MANY_TO_ONE:
         case ClassMetadataInfo::ONE_TO_ONE:
             $this->defineOneToOneField($formBuilder, $fieldDescription);
             break;
         default:
             list($type, $default_options) = $this->getFormTypeName($fieldDescription);
             $formBuilder->add($fieldDescription->getFieldName(), $type, array_merge($default_options, $fieldDescription->getOption('form_field_options', array())));
     }
 }
开发者ID:renegare,项目名称:AdminBundle,代码行数:36,代码来源:FormContractor.php

示例5: buildForm

 public function buildForm(FormBuilder $builder, array $options)
 {
     $data = $builder->getData();
     $builder->add('code', 'text', array('required' => false, 'label' => 'systemevents.code'))->add('description', 'textarea', array('required' => false, 'label' => 'systemevents.description'))->add('bundle', 'hidden')->add('entity', 'hidden')->add('type', 'choice', array('choices' => SystemEvents::getLimitedTypeTypes(), 'multiple' => false, 'empty_data' => null, 'required' => false, 'label' => 'systemevents.type'))->add('actions', 'hidden')->add('ownerType', 'hidden')->add('ownerId', 'hidden');
 }
开发者ID:r4cker,项目名称:lowbi,代码行数:5,代码来源:SystemEventsCreateType.php


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