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


PHP FormFactoryInterface::createNamed方法代码示例

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


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

示例1: handle

 /**
  * {@inheritdoc}
  */
 public function handle(Request $request, FormHandlerInterface $handler, FormInterface $form = null)
 {
     if (null !== $form) {
         $handler->setForm($form);
     } elseif (null === ($form = $handler->getForm())) {
         if ($handler instanceof NamedFormHandlerInterface && null !== ($name = $handler->getName())) {
             $form = $this->form_factory->createNamed($name, $handler->getType(), $handler->getData(), $handler->getOptions());
         } else {
             $form = $this->form_factory->create($handler->getType(), $handler->getData(), $handler->getOptions());
         }
         if (!$form instanceof FormInterface) {
             throw new FormNotFoundException($handler);
         }
         // set the form which is associated with the handler
         $handler->setForm($form);
     }
     $form->handleRequest($request);
     if (!$form->isSubmitted()) {
         return null;
     }
     if ($form->isValid()) {
         if ($handler instanceof FormSuccessHandlerInterface) {
             return $handler->onSuccess($request);
         }
     } elseif ($handler instanceof FormFailureHandlerInterface) {
         return $handler->onFailure($request);
     }
 }
开发者ID:hostnet,项目名称:form-handler-component,代码行数:31,代码来源:SimpleFormProvider.php

示例2: buildForm

 /**
  * Builds proper field form.
  *
  * @param FormEvent $event
  */
 public function buildForm(FormEvent $event)
 {
     if (null === ($fieldValue = $event->getData())) {
         return;
     }
     $form = $event->getForm();
     $options = array('label' => $fieldValue->getPresentation(), 'auto_initialize' => false, 'attr' => array('data-field-name' => $fieldValue->getName(), 'data-field-addable' => false));
     if (is_array($fieldValue->getConfiguration())) {
         $options = array_merge_recursive($options, $fieldValue->getConfiguration());
     }
     $name = 'value';
     if (FieldTypes::CHOICE === $fieldValue->getType()) {
         $option = $fieldValue->getField()->getOption();
         $sortBy = $fieldValue->getField()->getOrder();
         $type = new OptionValueChoiceType($option, $sortBy);
         if ($fieldValue->getAllowMultiple()) {
             $name = 'values';
             $options['multiple'] = true;
             $options['expanded'] = true;
         }
         $options['attr']['data-field-addable'] = $fieldValue->isAddable();
     } else {
         $type = $fieldValue->getType();
     }
     $form->remove('field')->add($this->factory->createNamed($name, $type, null, $options));
 }
开发者ID:upenn-dag,项目名称:dag-framework,代码行数:31,代码来源:BuildFieldValueFormListener.php

示例3: testSetInvalidYearsOption

 public function testSetInvalidYearsOption()
 {
     $help = 'Having trouble with the internets? Tell us about it.';
     $form = $this->factory->createNamed('__test___field', $this->getTestedType(), null, ['help' => $help]);
     $view = $form->createView();
     $this->assertSame($help, $view->vars['help']);
 }
开发者ID:tentwofour,项目名称:sf2-form,代码行数:7,代码来源:HelpTypeTest.php

示例4: addConfigurationFields

 /**
  * @param FormInterface $form
  * @param string        $ruleType
  * @param array         $data
  */
 protected function addConfigurationFields(FormInterface $form, $ruleType, array $data = [])
 {
     /** @var RuleCheckerInterface $checker */
     $checker = $this->checkerRegistry->get($ruleType);
     $configurationField = $this->factory->createNamed('configuration', $checker->getConfigurationFormType(), $data, ['auto_initialize' => false]);
     $form->add($configurationField);
 }
开发者ID:TeamNovatek,项目名称:Sylius,代码行数:12,代码来源:BuildRuleFormSubscriber.php

示例5: createAndHandle

 public function createAndHandle($name, $type, IEntity $entity)
 {
     $request = $this->request_stack->getMasterRequest();
     $form = $this->form_factory->createNamed($name, $type, $entity, ['method' => 'POST']);
     $form->handleRequest($request);
     return $form;
 }
开发者ID:Zemistr,项目名称:symfony-3-first-app,代码行数:7,代码来源:FormFactory.php

示例6: createForm

 /**
  * @return FormInterface
  */
 public function createForm()
 {
     $user = $this->userDiscriminator->getCurrentUserConfig();
     $type = $user->getFormType($this->type);
     $name = $user->getFormName($this->type);
     $validationGroups = $user->getFormValidationGroups($this->type);
     return $this->formFactory->createNamed($name, $type, null, array('validation_groups' => $validationGroups));
 }
开发者ID:buddhikajay,项目名称:RollerworksMultiUserBundle,代码行数:11,代码来源:FormFactory.php

示例7: addAttributeAsLabelField

 /**
  * @param FormEvent $event
  */
 public function addAttributeAsLabelField(FormEvent $event)
 {
     $data = $event->getData();
     if ($data instanceof FamilyInterface && $data->getId()) {
         $form = $event->getForm();
         $form->add($this->factory->createNamed('attributeAsLabel', 'entity', $data->getAttributeAsLabel(), ['required' => true, 'label' => 'Attribute used as label', 'class' => $this->attributeClass, 'choices' => $data->getAttributeAsLabelChoices(), 'auto_initialize' => false, 'select2' => true, 'disabled' => !$this->securityFacade->isGranted('pim_enrich_family_edit_properties')]));
     }
 }
开发者ID:abdeldayem,项目名称:pim-community-dev,代码行数:11,代码来源:AddAttributeAsLabelSubscriber.php

示例8: preSetData

 /**
  * @param FormEvent $event
  */
 public function preSetData(FormEvent $event)
 {
     $taxon = $event->getData();
     if (null === $taxon) {
         return;
     }
     $event->getForm()->add($this->factory->createNamed('parent', TaxonChoiceType::class, $taxon->getParent(), ['filter' => $this->getFilterTaxonOption($taxon), 'required' => false, 'label' => 'sylius.form.taxon.parent', 'placeholder' => '---', 'auto_initialize' => false]));
 }
开发者ID:sylius,项目名称:sylius,代码行数:11,代码来源:BuildTaxonFormSubscriber.php

示例9: preSetData

 /**
  * Builds proper taxon form after setting the product.
  *
  * @param FormEvent $event
  */
 public function preSetData(FormEvent $event)
 {
     $taxon = $event->getData();
     if (null === $taxon) {
         return;
     }
     $event->getForm()->add($this->factory->createNamed('parent', 'sylius_taxon_choice', $taxon->getParent(), array('taxonomy' => $taxon->getTaxonomy(), 'filter' => $this->getFilterTaxonOption($taxon), 'required' => false, 'label' => 'sylius.form.taxon.parent', 'empty_value' => '---', 'auto_initialize' => false)));
 }
开发者ID:lingoda,项目名称:Sylius,代码行数:13,代码来源:BuildTaxonFormSubscriber.php

示例10: populateEntityFromRequest

 /**
  * Return the populated entity if everything is ok,
  * if the data is not valid will throw a FormValidationException
  *
  * @param $formServiceName
  * @param $entityToPopulate
  *
  * @return FormInterface
  */
 public function populateEntityFromRequest($formServiceName, $entityToPopulate, $nameForm = '')
 {
     $form = $this->formFactory->createNamed($nameForm, $formServiceName, $entityToPopulate);
     $form->handleRequest($this->requestStack->getCurrentRequest());
     if (!$form->isSubmitted()) {
         $form->submit([]);
     }
     return $form;
 }
开发者ID:josecollazzi,项目名称:bigblue,代码行数:18,代码来源:ApiEntityExtractor.php

示例11: processForm

 /**
  * @param Request $request
  * @return View
  */
 private function processForm(Request $request)
 {
     $form = $this->formFactory->createNamed('', 'user_search');
     $form->handleRequest($request);
     if (!$form->isEmpty() && !$form->isValid()) {
         return new View($form, 400);
     }
     return new View($this->useCase->listUsers($form->getData()), 200);
 }
开发者ID:Nakard,项目名称:hexagonal_phonebook,代码行数:13,代码来源:ListUsersController.php

示例12: createForm

 /**
  * {@inheritdoc}
  */
 public function createForm(array $options = [], $data = null)
 {
     $options = array_merge(['validation_groups' => $this->validationGroups], $options);
     $form = $this->formFactory->createNamed($this->name, $this->type, null, $options);
     if (null !== $data) {
         $form->setData($data);
     }
     return $form;
 }
开发者ID:spomky-labs,项目名称:oauth2-server-bundle,代码行数:12,代码来源:FormFactory.php

示例13: create

 /**
  * {@inheritdoc}
  */
 public function create(RequestConfiguration $requestConfiguration, ResourceInterface $resource)
 {
     $formType = $requestConfiguration->getFormType();
     $formOptions = $requestConfiguration->getFormOptions();
     if ($requestConfiguration->isHtmlRequest()) {
         return $this->formFactory->create($formType, $resource, $formOptions);
     }
     return $this->formFactory->createNamed('', $formType, $resource, array_merge($formOptions, ['csrf_protection' => false]));
 }
开发者ID:sylius,项目名称:sylius,代码行数:12,代码来源:ResourceFormFactory.php

示例14: processForm

 /**
  * @param User $user
  * @param Request $request
  * @return View
  */
 private function processForm(User $user, Request $request)
 {
     $form = $this->formFactory->createNamed('', 'user_create', $user);
     $form->handleRequest($request);
     if (!$form->isValid()) {
         return new View($form, 400);
     }
     $this->useCase->createUser($user, false);
     return new View($user, 201, ['Location' => $this->router->generate('arkon_user_getUser', ['id' => $user->getId()], true)]);
 }
开发者ID:Nakard,项目名称:hexagonal_phonebook,代码行数:15,代码来源:CreateUserController.php

示例15: addConfigurationFields

 /**
  * @param FormEvent $event
  */
 public function addConfigurationFields(FormEvent $event)
 {
     $attribute = $event->getData();
     $form = $event->getForm();
     try {
         $requiredFields = $this->factory->createNamed('configuration', 'sylius_attribute_type_configuration_' . $attribute->getType(), null, ['auto_initialize' => false, 'label' => 'sylius.form.attribute_type.configuration']);
         $form->add($requiredFields);
     } catch (InvalidArgumentException $exception) {
     }
 }
开发者ID:ReissClothing,项目名称:Sylius,代码行数:13,代码来源:BuildAttributeFormSubscriber.php


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