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


PHP Form\FormFactory类代码示例

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


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

示例1: createForm

 /**
  * @param object                              $entity
  * @param \Symfony\Component\Form\FormFactory $formFactory
  * @param null                                $action
  * @param array                               $options
  *
  * @return \Symfony\Component\Form\FormInterface
  */
 public function createForm($entity, $formFactory, $action = null, $options = [])
 {
     $fields = $this->leadFieldModel->getFieldListWithProperties();
     $choices = [];
     foreach ($fields as $alias => $field) {
         if (!isset($choices[$field['group_label']])) {
             $choices[$field['group_label']] = [];
         }
         $choices[$field['group_label']][$alias] = $field['label'];
     }
     // Only show the lead fields not already used
     $usedLeadFields = $this->session->get('mautic.form.' . $entity['formId'] . '.fields.leadfields', []);
     $testLeadFields = array_flip($usedLeadFields);
     $currentLeadField = isset($entity['leadField']) ? $entity['leadField'] : null;
     if (!empty($currentLeadField) && isset($testLeadFields[$currentLeadField])) {
         unset($testLeadFields[$currentLeadField]);
     }
     foreach ($choices as &$group) {
         $group = array_diff_key($group, $testLeadFields);
     }
     $options['leadFields'] = $choices;
     $options['leadFieldProperties'] = $fields;
     if ($action) {
         $options['action'] = $action;
     }
     return $formFactory->create('formfield', $entity, $options);
 }
开发者ID:dongilbert,项目名称:mautic,代码行数:35,代码来源:FieldModel.php

示例2: array

 function it_returns_form_builder_with_additional_file_options_and_file_constraints(FormFactory $factory, FormBuilder $form, NotBlank $constraint)
 {
     $this->addConstraint($constraint);
     $this->setFormOptions(array('file_type' => 'fsi_image', 'file_options' => array('file_option' => 'value')));
     $factory->createNamedBuilder('fileValue', 'fsi_removable_file', null, array('label' => false, 'required' => false, 'file_type' => 'fsi_image', 'file_options' => array('file_option' => 'value', 'constraints' => array($constraint))))->shouldBeCalled()->willReturn($form);
     $this->getFormBuilder($factory)->shouldReturn($form);
 }
开发者ID:norzechowicz,项目名称:resource-repository-bundle,代码行数:7,代码来源:FSiRemovableFileTypeSpec.php

示例3: createForm

 /**
  * {@inheritdoc}
  *
  * @param object                              $entity
  * @param \Symfony\Component\Form\FormFactory $formFactory
  * @param null                                $action
  * @param array                               $options
  *
  * @throws NotFoundHttpException
  */
 public function createForm($entity, $formFactory, $action = null, $options = [])
 {
     if (!$entity instanceof Focus) {
         throw new MethodNotAllowedHttpException(['Focus']);
     }
     if (!empty($action)) {
         $options['action'] = $action;
     }
     return $formFactory->create('focus', $entity, $options);
 }
开发者ID:dongilbert,项目名称:mautic,代码行数:20,代码来源:FocusModel.php

示例4: resolveItemToAdd

 /**
  * {@inheritdoc}
  */
 public function resolveItemToAdd(Request $request)
 {
     /*
      * We're getting here product set id via query but you can easily override route
      * pattern and use attributes, which are available through request object.
      */
     if ($id = $request->query->get('id')) {
         if ($product_set = $this->productSetManager->findSet($id)) {
             /*
              * To have it flexible, we allow adding single item by GET request
              * and also user can provide desired quantity by form via POST request.
              */
             $item = $this->itemManager->createItem();
             $item->setProductSet($product_set);
             if ('POST' === $request->getMethod()) {
                 $form = $this->formFactory->create('chewbacca_cart_item');
                 $form->setData($item);
                 $form->bindRequest($request);
                 if (!$form->isValid()) {
                     return false;
                 }
             }
             return $item;
         }
     }
 }
开发者ID:hd-deman,项目名称:Chewbacca,代码行数:29,代码来源:ItemResolver.php

示例5: postGameAction

 public function postGameAction(Request $request)
 {
     $uuid = $this->uuidGenerator->generate();
     $gameStartCommand = new GameStartCommand($uuid, "hup");
     $form = $this->formFactory->create(new GameStartType(), $gameStartCommand);
     $this->handleForm($request, $form, $uuid, $gameStartCommand);
 }
开发者ID:weemen,项目名称:hangman_lennard,代码行数:7,代码来源:DefaultController.php

示例6: boxAction

 /**
  * @Template(":Todo/Search:box.html.twig")
  * @return array
  */
 public function boxAction(Request $request)
 {
     $search = new TodoList();
     $form = $this->formFactory->create('todo_list', $search);
     $form->handleRequest($request);
     return ['form' => $form->createView()];
 }
开发者ID:polidog,项目名称:symfony_sample_todo,代码行数:11,代码来源:SearchController.php

示例7: process

 /**
  * Process form
  *
  * @param  Call $entity
  *
  * @return bool  True on successful processing, false otherwise
  */
 public function process(Call $entity)
 {
     $targetEntityClass = $this->request->get('entityClass');
     $targetEntityId = $this->request->get('entityId');
     $options = [];
     if ($targetEntityClass && $this->request->getMethod() === 'GET') {
         $targetEntity = $this->entityRoutingHelper->getEntity($targetEntityClass, $targetEntityId);
         if (!$entity->getId()) {
             $entity->setPhoneNumber($this->phoneProvider->getPhoneNumber($targetEntity));
         }
         $options = ['phone_suggestions' => array_unique(array_map(function ($item) {
             return $item[0];
         }, $this->phoneProvider->getPhoneNumbers($targetEntity)))];
     }
     $this->form = $this->formFactory->createNamed($this->formName, $this->formType, $entity, $options);
     $this->form->setData($entity);
     if (in_array($this->request->getMethod(), array('POST', 'PUT'))) {
         $this->form->submit($this->request);
         if ($this->form->isValid()) {
             if ($targetEntityClass) {
                 $targetEntity = $this->entityRoutingHelper->getEntity($targetEntityClass, $targetEntityId);
                 $this->callActivityManager->addAssociation($entity, $targetEntity);
                 $phones = $this->phoneProvider->getPhoneNumbers($targetEntity);
                 foreach ($phones as $phone) {
                     if ($entity->getPhoneNumber() === $phone[0]) {
                         $this->callActivityManager->addAssociation($entity, $phone[1]);
                     }
                 }
             }
             $this->onSuccess($entity);
             return true;
         }
     }
     return false;
 }
开发者ID:rodolfobandeira,项目名称:crm,代码行数:42,代码来源:CallHandler.php

示例8: createFormBuilder

 /**
  * Obtains any form metadata from the entity and adds itself to the form
  * @param $entity
  * @param $form
  * @return
  */
 public function createFormBuilder($entity, $data = null, array $options = array())
 {
     // Build the $form
     $formBuilder = $this->factory->createBuilder('form', $data, $options);
     // Read the entity meta data and add to the form
     if (empty($this->drivers)) {
         return $formBuilder;
     }
     // Look to the readers to find metadata
     foreach ($this->drivers as $driver) {
         $metadata = $driver->getMetadata($entity);
         if (!empty($metadata)) {
             break;
         }
     }
     if (empty($metadata)) {
         return $formBuilder;
     }
     // Configure the form
     $fields = $metadata->getFields();
     foreach ($fields as $field) {
         // TODO: Detect "new x()" in field value or type option for AbstractType creation
         // TODO: Detect references to "%service.id%" for service constructor dependency
         $formBuilder->add($field->name, $field->value, $field->options);
     }
     return $formBuilder;
 }
开发者ID:flintlabs,项目名称:formmetadatabundle,代码行数:33,代码来源:FormMapper.php

示例9: createToggleAccessOption

 /**
  * Creates toggle access option.
  *
  * @return Form
  */
 public function createToggleAccessOption()
 {
     /** @var FormBuilder $formBuilder */
     $formBuilder = $this->formFactory->createBuilder('form');
     $form = $formBuilder->add('submit', 'submit', ['attr' => ['class' => 'btn']])->getForm();
     return $form;
 }
开发者ID:daniel-iwaniec,项目名称:ISI-PRO,代码行数:12,代码来源:ListOptionCreator.php

示例10: getLoginForm

 /**
  * @param null $data
  * @param array $options
  * @return \Symfony\Component\Form\Form
  */
 public function getLoginForm($data = null, array $options = [])
 {
     $options['last_username'] = $this->authenticationUtils->getLastUsername();
     if (!array_key_exists('action', $options)) {
         $options['action'] = $this->router->generate('security_login_check');
     }
     return $this->formFactory->create(LoginType::class, $data, $options);
 }
开发者ID:ampisoft,项目名称:user-bundle,代码行数:13,代码来源:FormManager.php

示例11: createAction

 /**
  * @Route("/users/new", name="user_new")
  * @Template("BigfishUserBundle:Default:form.html.twig")
  */
 public function createAction(Request $request)
 {
     $user = $this->_security->getToken()->getUser();
     $entity = $this->_userManager->createUser();
     $form = $this->_formFactory->create(new UserType(), $entity);
     //        $this->_formFactory->create(, $data, $options);
     return array('form' => $form->createView());
 }
开发者ID:BigfishCMF,项目名称:UserBundle,代码行数:12,代码来源:DefaultController.php

示例12: shouldNotBindInvalidValue

    /**
     * @test
     */
    public function shouldNotBindInvalidValue()
    {
        $form = $this->formFactory->create('payum_payment_factories_choice');

        $form->submit('invalid');

        $this->assertNull($form->getData());
    }
开发者ID:xxspartan16,项目名称:BMS-Market,代码行数:11,代码来源:PaymentFactoriesChoiceTypeTest.php

示例13: createForm

 /**
  * Create form for role manipulation
  *
  * @param Role $role
  * @return FormInterface
  */
 public function createForm(Role $role)
 {
     foreach ($this->privilegeConfig as $configName => $config) {
         $this->privilegeConfig[$configName]['permissions'] = $this->aclManager->getPrivilegeRepository()->getPermissionNames($config['types']);
     }
     $this->form = $this->formFactory->create(new ACLRoleType($this->privilegeConfig), $role);
     return $this->form;
 }
开发者ID:noglitchyo,项目名称:pim-community-dev,代码行数:14,代码来源:AclRoleHandler.php

示例14: testLayout

 /**
  * @dataProvider layoutProvider
  */
 public function testLayout($formOptions, $formItems, $expectedBlocks)
 {
     $formBuilder = $this->factory->createNamedBuilder('test', 'form', null, $formOptions);
     $this->buildForm($formBuilder, $formItems);
     $formView = $formBuilder->getForm()->createView();
     $result = $this->builder->build($formView);
     $expected = $this->getBlocks($expectedBlocks);
     $this->assertEquals($expected, $result->toArray());
 }
开发者ID:Maksold,项目名称:platform,代码行数:12,代码来源:DataBlockBuilderTest.php

示例15: buildForm

 public function buildForm()
 {
     $def = $this->definitions[$this->getCurrentStep()];
     $methodName = 'build' . implode('', array_map('ucfirst', explode('-', $this->getCurrentStep()))) . 'Form';
     $builder = $this->formFactory->createBuilder('form', $this->getSubject(), array('validation_groups' => $def['validation_groups']));
     $this->{$methodName}($builder);
     $form = $builder->getForm();
     return $form;
 }
开发者ID:roomthirteen,项目名称:Room13WizardBundle,代码行数:9,代码来源:Wizard.php


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