當前位置: 首頁>>代碼示例>>PHP>>正文


PHP FormInterface::createView方法代碼示例

本文整理匯總了PHP中Symfony\Component\Form\FormInterface::createView方法的典型用法代碼示例。如果您正苦於以下問題:PHP FormInterface::createView方法的具體用法?PHP FormInterface::createView怎麽用?PHP FormInterface::createView使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Symfony\Component\Form\FormInterface的用法示例。


在下文中一共展示了FormInterface::createView方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1:

 function it_builds_view(FormConfigInterface $config, FormView $view, FormInterface $form, FormInterface $prototype)
 {
     $form->getConfig()->willReturn($config);
     $config->getAttribute('prototypes')->willReturn(['configuration_kind' => $prototype]);
     $prototype->createView($view)->shouldBeCalled();
     $this->buildView($view, $form, []);
 }
開發者ID:loic425,項目名稱:Sylius,代碼行數:7,代碼來源:PromotionActionCollectionTypeSpec.php

示例2: testProgressToConfirm

 public function testProgressToConfirm()
 {
     $this->form->submit(['_operation' => ['confirm' => '']]);
     $view = $this->form->createView();
     $this->assertCount(2, $view['_operation']);
     $this->assertArrayHasKey('back', $view['_operation']);
     $this->assertArrayHasKey('commit', $view['_operation']);
 }
開發者ID:issei-m,項目名稱:confirmable-form,代碼行數:8,代碼來源:FormTypeOperationExtensionTest.php

示例3: getData

 /**
  * {@inheritdoc}
  */
 public function getData()
 {
     $data = array('form' => $this->form->createView(), 'element' => $this->element);
     if ($this->form->getData()) {
         $data['id'] = $this->element->getDataIndexer()->getIndex($this->form->getData());
     }
     return $data;
 }
開發者ID:kbedn,項目名稱:admin-bundle,代碼行數:11,代碼來源:FormElementContext.php

示例4: testViewData

 public function testViewData()
 {
     $view = $this->form->createView();
     $choices = $view->vars['choices'];
     $data = array();
     foreach ($choices as $choice) {
         $data[] = $choice->data;
     }
     $query = $this->app['eccube.repository.mail_template']->createQueryBuilder('m')->orderBy('m.id', 'ASC')->getQuery();
     $res = $query->getResult();
     // order by されているか
     $this->assertEquals($data, $res);
 }
開發者ID:hiroyasu55,項目名稱:ec-cube,代碼行數:13,代碼來源:MailTemplateTypeTest.php

示例5: changePasswordAction

 public function changePasswordAction(Request $request)
 {
     $this->changePasswordForm->handleRequest($request);
     if ($this->changePasswordForm->isValid()) {
         $user = $this->tokenStorage->getToken()->getUser();
         $formData = $this->changePasswordForm->getData();
         $this->eventDispatcher->dispatch(AdminSecurityEvents::CHANGE_PASSWORD, new ChangePasswordEvent($user, $formData['plainPassword']));
         $request->getSession()->invalidate();
         $this->tokenStorage->setToken(null);
         $request->getSession()->getFlashBag()->set('success', 'admin.change_password_message.success');
         return new RedirectResponse($this->router->generate('fsi_admin_security_user_login'));
     }
     return $this->templating->renderResponse($this->changePasswordActionTemplate, array('form' => $this->changePasswordForm->createView()));
 }
開發者ID:szymach,項目名稱:admin-security-bundle,代碼行數:14,代碼來源:AdminController.php

示例6: createAction

 /**
  * {@inheritdoc}
  *
  * @Template
  * @AclAncestor("pim_enrich_variant_group_create")
  */
 public function createAction(Request $request)
 {
     if (!$request->isXmlHttpRequest()) {
         return new RedirectResponse($this->router->generate('pim_enrich_variant_group_index'));
     }
     $group = $this->groupFactory->createGroup('VARIANT');
     $group->setProductTemplate($this->productTemplateBuilder->createProductTemplate());
     if ($this->groupHandler->process($group)) {
         $request->getSession()->getFlashBag()->add('success', new Message('flash.variant group.created'));
         $url = $this->router->generate('pim_enrich_variant_group_edit', ['code' => $group->getCode()]);
         $response = ['status' => 1, 'url' => $url];
         return new Response(json_encode($response));
     }
     return ['form' => $this->groupForm->createView()];
 }
開發者ID:a2xchip,項目名稱:pim-community-dev,代碼行數:21,代碼來源:VariantGroupController.php

示例7: createView

 /**
  * Creates a view.
  *
  * @param FormView $parent The parent view
  *
  * @return FormView The view
  */
 public function createView(FormView $parent = null)
 {
     if (null === $parent && $this->parent) {
         $parent = $this->parent->createView();
     }
     $view = new FormView();
     $view->setParent($parent);
     $types = (array) $this->types;
     foreach ($types as $type) {
         $type->buildView($view, $this);
         foreach ($type->getExtensions() as $typeExtension) {
             $typeExtension->buildView($view, $this);
         }
     }
     $childViews = array();
     foreach ($this->children as $key => $child) {
         $childViews[$key] = $child->createView($view);
     }
     $view->setChildren($childViews);
     foreach ($types as $type) {
         $type->buildViewBottomUp($view, $this);
         foreach ($type->getExtensions() as $typeExtension) {
             $typeExtension->buildViewBottomUp($view, $this);
         }
     }
     return $view;
 }
開發者ID:rudott,項目名稱:symfony,代碼行數:34,代碼來源:Form.php

示例8: convertMeta

 /**
  * @param FormInterface $form
  *
  * @return array
  */
 public function convertMeta(FormInterface $form)
 {
     $formView = $form->createView();
     $fields = array();
     foreach ($formView->children as $name => $child) {
         $fields[$name] = array('default' => $child->vars['data'], 'label' => $child->vars['label'], 'required' => $child->vars['required']);
         if (in_array('checkbox', $child->vars['block_prefixes'])) {
             $fields[$name]['type'] = 'checkbox';
         } else {
             if (in_array('password', $child->vars['block_prefixes'])) {
                 $fields[$name]['type'] = 'password';
             } elseif (in_array('choice', $child->vars['block_prefixes'])) {
                 $fields[$name]['type'] = 'choice';
                 $fields[$name]['choices'] = array_values($child->vars['choices']);
             } elseif (in_array('text', $child->vars['block_prefixes'])) {
                 $fields[$name]['type'] = 'text';
             } elseif (in_array('number', $child->vars['block_prefixes'])) {
                 $fields[$name]['type'] = 'text';
             } else {
                 $fields[$name]['type'] = 'form';
                 $fields[$name]['children'] = $this->convertMeta($form->get($name));
             }
         }
     }
     return $fields;
 }
開發者ID:itmox,項目名稱:PayumServer,代碼行數:31,代碼來源:FormToJsonConverter.php

示例9: editAction

 /**
  * Edit a group
  *
  * TODO : find a way to use param converter with interfaces
  *
  * @param Group $group
  *
  * @Template
  * @AclAncestor("pim_enrich_group_edit")
  *
  * @return array
  */
 public function editAction(Group $group)
 {
     if ($this->groupHandler->process($group)) {
         $this->request->getSession()->getFlashBag()->add('success', new Message('flash.group.updated'));
     }
     return ['form' => $this->groupForm->createView(), 'currentGroup' => $group->getId()];
 }
開發者ID:userz58,項目名稱:pim-community-dev,代碼行數:19,代碼來源:GroupController.php

示例10: testViewData

 public function testViewData()
 {
     $view = $this->form->createView();
     $choices = $view->vars['choices'];
     // empty_value
     $this->assertEquals($view->vars['empty_value'], 'form.pref.empty_value');
     $data = array();
     // attrなど含まれているので
     foreach ($choices as $choice) {
         $data[] = $choice->data;
     }
     $query = $this->app['eccube.repository.master.pref']->createQueryBuilder('p')->orderBy('p.rank', 'ASC')->getQuery();
     $pref = $query->getResult();
     // order by されているか
     $this->assertEquals($data, $pref);
 }
開發者ID:hiroyasu55,項目名稱:ec-cube,代碼行數:16,代碼來源:PrefTypeTest.php

示例11:

 function it_builds_view(FormView $view, FormInterface $form, FormConfigInterface $formConfig)
 {
     $form->getConfig()->shouldBeCalled()->willReturn($formConfig);
     $formConfig->getAttribute('prototypes')->shouldBeCalled()->willReturn(['type' => $form]);
     $form->createView($view)->shouldBeCalled();
     $this->buildView($view, $form, []);
 }
開發者ID:loic425,項目名稱:Sylius,代碼行數:7,代碼來源:PriceableTypeExtensionSpec.php

示例12: createView

 /**
  * {@inheritdoc}
  */
 public function createView(FormView $parent = null)
 {
     if (null === $parent && $this->parent) {
         $parent = $this->parent->createView();
     }
     return $this->config->getType()->createView($this, $parent);
 }
開發者ID:senthil-r-wiredelta,項目名稱:meilleure-visite,代碼行數:10,代碼來源:Form.php

示例13: onConfig

 /**
  * @DI\Observe("widget_badge_usage_configuration")
  *
  * @param ConfigureWidgetEvent $event
  */
 public function onConfig(ConfigureWidgetEvent $event)
 {
     $badgeWidgetConfig = $this->badgeWidgetManager->getBadgeUsageConfigForInstance($event->getInstance());
     $this->badgeUsageForm->setData($badgeWidgetConfig);
     $content = $this->templating->render('IcapBadgeBundle:Widget:badge_usage_config.html.twig', ['form' => $this->badgeUsageForm->createView(), 'instance' => $event->getInstance()]);
     $event->setContent($content);
 }
開發者ID:claroline,項目名稱:distribution,代碼行數:12,代碼來源:BadgeUsageWidgetListener.php

示例14: getView

 /**
  * @return FormView
  */
 public function getView()
 {
     if (!$this->view) {
         $this->view = $this->form->createView();
         $this->onCreateView($this->view, $this);
     }
     return $this->view;
 }
開發者ID:Arachne,項目名稱:Forms,代碼行數:11,代碼來源:FormComponent.php

示例15: array

 /**
  * @param \Symfony\Bundle\FrameworkBundle\Templating\EngineInterface $templating
  * @param \Symfony\Component\Form\FormInterface $form
  * @param \Symfony\Component\Form\FormView $formView
  * @param \Symfony\Component\HttpFoundation\Request $request
  * @param \Symfony\Component\HttpFoundation\Response $response
  */
 function it_render_template_with_change_password_form($templating, $form, $formView, $request, $response)
 {
     $form->handleRequest($request)->shouldBeCalled();
     $form->isValid()->shouldBeCalled()->willReturn(false);
     $form->createView()->shouldBeCalled()->willReturn($formView);
     $templating->renderResponse('FSiAdminSecurityBundle:Admin:change_password.html.twig', array('form' => $formView))->shouldBeCalled()->willReturn($response);
     $this->changePasswordAction($request)->shouldReturn($response);
 }
開發者ID:szymach,項目名稱:admin-security-bundle,代碼行數:15,代碼來源:AdminControllerSpec.php


注:本文中的Symfony\Component\Form\FormInterface::createView方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。