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


PHP FormFactoryInterface::createNamedBuilder方法代码示例

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


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

示例1: create

 /**
  * {@inheritdoc}
  */
 public function create($pollId)
 {
     $type = $this->formFactory->getType($this->type);
     $type->setPollFields($pollId);
     $builder = $this->formFactory->createNamedBuilder(sprintf('%s_%s', $this->name, $pollId), $type);
     return $builder->getForm();
 }
开发者ID:titimoun,项目名称:BaitPollBundle,代码行数:10,代码来源:PollFormFactory.php

示例2: getForm

 /**
  * {@inheritdoc}
  */
 public function getForm($group)
 {
     $block = $this->getSubtree($group);
     $toAdd = array();
     $bc = $block->toBlockConfig();
     if (!$block->isEmpty()) {
         $sbc = array();
         /** @var $subblock GroupNodeDefinition */
         foreach ($block as $subblock) {
             $sbc += $subblock->toBlockConfig();
             if (!$subblock->isEmpty()) {
                 /** @var $field FieldNodeDefinition */
                 foreach ($subblock as $field) {
                     $field->replaceOption('block', $block->getName())->replaceOption('subblock', $subblock->getName());
                     $toAdd[] = $field;
                 }
             }
         }
         $bc[$block->getName()]['subblocks'] = $sbc;
     }
     $fb = $this->factory->createNamedBuilder($group, 'oro_config_form_type', null, array('block_config' => $bc));
     foreach ($toAdd as $field) {
         $this->addFieldToForm($fb, $field);
     }
     return $fb->getForm();
 }
开发者ID:noglitchyo,项目名称:pim-community-dev,代码行数:29,代码来源:SystemConfigurationFormProvider.php

示例3: create

 /**
  * {@inheritdoc}
  */
 public function create($id)
 {
     $type = $this->formFactory->getType($this->type);
     $type->setId($id);
     $builder = $this->formFactory->createNamedBuilder($type, sprintf('%s_%s', $this->name, $id));
     return $builder->getForm();
 }
开发者ID:rafix,项目名称:BaitPollBundle,代码行数:10,代码来源:PollFormFactory.php

示例4: getForm

 /**
  * @param string $widget
  *
  * @return FormInterface
  * @throws InvalidArgumentException
  */
 public function getForm($widget)
 {
     if (!$this->hasForm($widget)) {
         throw new InvalidArgumentException(sprintf('Can\'t find form for widget "%s"', $widget));
     }
     $widgetConfig = $this->configProvider->getWidgetConfig($widget);
     $fields = $widgetConfig[static::FORM_FIELDS_KEY];
     $builder = $this->formFactory->createNamedBuilder($widget);
     foreach ($fields as $name => $config) {
         $field = new FieldNodeDefinition($name, $config);
         $builder->add($field->getName(), $config['type'], $field->getOptions());
     }
     return $builder->getForm();
 }
开发者ID:snorchel,项目名称:platform,代码行数:20,代码来源:WidgetConfigurationFormProvider.php

示例5: createComponentForm

 /**
  * @return FormComponent
  */
 protected function createComponentForm()
 {
     $builder = $this->formFactory->createNamedBuilder($this->lookupPath('Nette\\Application\\UI\\Presenter'), $this->type, $this->entity, $this->options);
     $component = $this->formComponentFactory->create($builder->getForm());
     if ($this->theme) {
         $component->onCreateView[] = function ($view, $component) {
             $component->getRenderer()->setTheme($view, $this->theme);
         };
     }
     $component->onSuccess[] = function ($entity) {
         $this->processForm($entity);
     };
     return $component;
 }
开发者ID:enumag,项目名称:arachne-forms-example,代码行数:17,代码来源:EntityForm.php

示例6: testEmbedLabelPrefix

 public function testEmbedLabelPrefix()
 {
     $embedForm = $this->factory->createNamedBuilder($embedFormName = 'embed_form', FormType::class, null, ['label_prefix' => $embedLabelPrefix = 'embed_prefix'])->add($embedFieldName = 'embed_field');
     $form = $this->factory->createBuilder(FormType::class, null, ['label_prefix' => $labelPrefix = 'prefix'])->add($embedForm)->add($fieldName = 'field')->getForm()->submit([]);
     $view = $form->createView();
     $fieldView = $view->children[$fieldName];
     $embedFormView = $view->children[$embedFormName];
     $embedFieldView = $embedFormView->children[$embedFieldName];
     $this->assertArrayHasKey('label', $fieldView->vars);
     $this->assertSame($labelPrefix . '.' . $fieldName, $fieldView->vars['label']);
     $this->assertArrayHasKey('label', $embedFormView->vars);
     $this->assertSame($labelPrefix . '.' . $embedFormName, $embedFormView->vars['label']);
     $this->assertArrayHasKey('label', $embedFieldView->vars);
     $this->assertSame($embedLabelPrefix . '.' . $embedFieldName, $embedFieldView->vars['label']);
 }
开发者ID:blazarecki,项目名称:lug,代码行数:15,代码来源:LabelFormExtensionTest.php

示例7: createComponentForm

 /**
  * @return FormComponent
  */
 protected function createComponentForm()
 {
     $builder = $this->formFactory->createNamedBuilder($this->lookupPath('Nette\\Application\\UI\\Presenter'), 'form', null, []);
     $builder->add('firstname');
     $builder->add('lastname');
     $builder->add('email');
     $builder->add('text');
     $component = $this->formComponentFactory->create($builder->getForm());
     $component->onSuccess[] = function (array $data) {
         // process data
         $this->getPresenter()->flashMessage('The form has been sucessfully sent.');
         $this->getPresenter()->redirect('this');
     };
     return $component;
 }
开发者ID:enumag,项目名称:arachne-forms-example,代码行数:18,代码来源:CustomForm.php

示例8: buildBasketElements

 /**
  * @throws \Symfony\Component\Form\Exception\UnexpectedTypeException
  *
  * @param $form
  * @param $basketElements
  */
 private function buildBasketElements($form, $basketElements)
 {
     if (null === $basketElements) {
         return;
     }
     if (!$basketElements instanceof \ArrayAccess && !is_array($basketElements)) {
         throw new UnexpectedTypeException($basketElements, 'array or \\ArrayAccess');
     }
     foreach ($basketElements as $basketElement) {
         $basketElementBuilder = $this->factory->createNamedBuilder($basketElement->getPosition(), 'form', $basketElement, array('property_path' => '[' . $basketElement->getPosition() . ']', 'auto_initialize' => false));
         $basketElementBuilder->setErrorBubbling(false);
         $provider = $basketElement->getProductProvider();
         $provider->defineBasketElementForm($basketElement, $basketElementBuilder);
         $form->add($basketElementBuilder->getForm());
     }
 }
开发者ID:lzdv,项目名称:ecommerce,代码行数:22,代码来源:BasketResizeFormListener.php

示例9: getFormBuilder

 /**
  * {@inheritdoc}
  */
 public function getFormBuilder(FormFactoryInterface $factory)
 {
     if (!isset($this->formBuilder)) {
         $this->formBuilder = $factory->createNamedBuilder($this->getResourceProperty(), $this->getFormType(), null, $this->buildFormOptions());
     }
     return $this->formBuilder;
 }
开发者ID:norzechowicz,项目名称:resource-repository-bundle,代码行数:10,代码来源:AbstractType.php

示例10: getFormAddBasket

 /**
  * Returns a "add to basket" form for a specified product.
  *
  * @param ProductInterface $product A product instance
  *
  * @return FormView
  */
 public function getFormAddBasket(ProductInterface $product)
 {
     $formBuilder = $this->formFactory->createNamedBuilder('add_basket', 'form', null, array('data_class' => $this->basketElementClass, 'csrf_protection' => false));
     $this->productPool->getProvider($product)->defineAddBasketForm($product, $formBuilder, false);
     $form = $formBuilder->getForm()->createView();
     return $form;
 }
开发者ID:kinkinweb,项目名称:lhvb,代码行数:14,代码来源:ProductExtension.php

示例11: createAclRolesForm

 /**
  * Gets the ACL roles form.
  *
  * @param \Sonata\AdminBundle\Util\AdminObjectAclData $data
  *
  * @return \Symfony\Component\Form\Form
  */
 public function createAclRolesForm(AdminObjectAclData $data)
 {
     $aclValues = $data->getAclRoles();
     $formBuilder = $this->formFactory->createNamedBuilder(self::ACL_ROLES_FORM_NAME, 'form');
     $form = $this->buildForm($data, $formBuilder, $aclValues);
     $data->setAclRolesForm($form);
     return $form;
 }
开发者ID:netounet,项目名称:SonataAdminBundle,代码行数:15,代码来源:AdminObjectAclManipulator.php

示例12: initForm

 protected function initForm(FormFactoryInterface $factory, $data = null)
 {
     $builder = $factory->createNamedBuilder('subscriber', 'form', $data, array('data_class' => $this->getClassName()));
     $builder->add('email', 'email', array('label' => 'admin.subscriber.list.email'));
     $builder->add('created_at', 'date', array('label' => 'admin.subscriber.list.created_at', 'widget' => 'single_text'));
     $builder->add('active', 'checkbox', array('label' => 'admin.subscriber.list.active'));
     return $builder->getForm();
 }
开发者ID:kbedn,项目名称:admin-bundle,代码行数:8,代码来源:SubscriberForm.php

示例13: create

 /**
  * {@inheritdoc}
  */
 public function create($name, $type = null, array $options = array())
 {
     if (null === $type && null === $this->getDataClass()) {
         $type = 'text';
     }
     if (null !== $type) {
         return $this->factory->createNamedBuilder($name, $type, null, $options, $this);
     }
     return $this->factory->createBuilderForProperty($this->getDataClass(), $name, null, $options, $this);
 }
开发者ID:nathanlon,项目名称:symfony,代码行数:13,代码来源:FormBuilder.php

示例14: getForm

 /**
  * Returns a form with defined parameters.
  *
  * @param  array $options
  *
  * @return Form
  */
 public function getForm($options = array())
 {
     $options['csrf_protection'] = false;
     $parameters = $this->getParameters();
     $builder = $this->factory->createNamedBuilder('', 'form', $parameters, $options);
     foreach ($parameters as $key => $value) {
         $builder->add($key, 'hidden');
     }
     return $builder->getForm();
 }
开发者ID:ybensacq,项目名称:LexikPayboxBundle,代码行数:17,代码来源:Request.php

示例15: initForm

 protected function initForm(FormFactoryInterface $factory, $data = null)
 {
     $builder = $factory->createNamedBuilder('news', 'form', $data, array('data_class' => $this->getClassName()));
     $builder->add('title', 'text', array('label' => 'admin.news.list.title'));
     $builder->add('date', 'date', array('label' => 'admin.news.list.date', 'widget' => 'single_text', 'required' => false));
     $builder->add('created_at', 'date', array('label' => 'admin.news.list.created_at', 'widget' => 'single_text'));
     $builder->add('visible', 'checkbox', array('label' => 'admin.news.list.visible', 'required' => false));
     $builder->add('creator_email', 'email', array('label' => 'admin.news.list.creator_email'));
     $builder->add('photo', 'fsi_image', array('label' => 'admin.news.list.photo'));
     $builder->add('tags', 'collection', array('type' => new TagType(), 'label' => 'admin.news.list.tags', 'allow_add' => true, 'allow_delete' => true, 'by_reference' => false));
     return $builder->getForm();
 }
开发者ID:kbedn,项目名称:admin-bundle,代码行数:12,代码来源:News.php


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