本文整理汇总了PHP中Symfony\Component\Form\FormBuilder::getForm方法的典型用法代码示例。如果您正苦于以下问题:PHP FormBuilder::getForm方法的具体用法?PHP FormBuilder::getForm怎么用?PHP FormBuilder::getForm使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Symfony\Component\Form\FormBuilder
的用法示例。
在下文中一共展示了FormBuilder::getForm方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: let
public function let(ArticleService $articleService, AuthorService $authorService, CacheService $cacheService, Container $container, ArticleRepository $articleRepository, LanguageRepository $languageRepository, ArticleTypeRepository $articleTypeRepository, PublicationRepository $publicationRepository, IssueRepository $issueRepository, SectionRepository $sectionRepository, AuthorTypeRepository $authorTypeRepository, EntityManager $entityManager, Request $request, FormFactory $formFactory, FormBuilder $formBuilder, Form $form, FormView $formView, User $user, UserService $userService, Article $article, Publication $publication, ArticleType $articleType, Issue $issue, Section $section, Language $language, Author $author, AuthorType $authorType, AbstractQuery $query, SecurityContext $security, TokenInterface $token, Router $router)
{
$container->get('em')->willReturn($entityManager);
$container->get('request')->willReturn($request);
$container->get('user')->willReturn($userService);
$container->get('form.factory')->willReturn($formFactory);
$container->get('newscoop_newscoop.article_service')->willReturn($articleService);
$container->get('author')->willReturn($authorService);
$container->get('newscoop.cache')->willReturn($cacheService);
$container->get('router')->willReturn($router);
$formBuilder->getForm(Argument::cetera())->willReturn($form);
$formFactory->create(Argument::cetera())->willReturn($form);
$form->createView()->willReturn($formView);
$form->handleRequest(Argument::cetera())->willReturn(true);
$form->isValid()->willReturn(true);
$security->getToken()->willReturn($token);
$container->get('security.context')->willReturn($security);
$container->has('security.context')->willReturn(true);
$this->setContainer($container);
$entityManager->getRepository('Newscoop\\Entity\\Article')->willReturn($articleRepository);
$entityManager->getRepository('Newscoop\\Entity\\Language')->willReturn($languageRepository);
$entityManager->getRepository('Newscoop\\Entity\\ArticleType')->willReturn($articleTypeRepository);
$entityManager->getRepository('Newscoop\\Entity\\Publication')->willReturn($publicationRepository);
$entityManager->getRepository('Newscoop\\Entity\\Issue')->willReturn($issueRepository);
$entityManager->getRepository('Newscoop\\Entity\\Section')->willReturn($sectionRepository);
$entityManager->getRepository('Newscoop\\Entity\\AuthorType')->willReturn($authorTypeRepository);
$articleRepository->getArticle(Argument::cetera())->willReturn($query);
$entityManager->flush(Argument::any())->willReturn(true);
$userService->getCurrentUser()->willReturn($user);
$number = 64;
$language = "en";
}
示例2: let
public function let(Container $container, Translator $translator, Session $session, TopicRepository $topicRepository, EntityRepository $repository, EntityManager $entityManager, Request $request, FormFactory $formFactory, FormBuilder $formBuilder, Form $form, FormView $formView, Topic $topic, CsrfTokenManagerAdapter $csrfTokenManagerAdapter, AbstractQuery $query, AbstractQuery $query2, ParameterBag $parameterBag, ArticleTopicRepository $articleTopicrepository, UserService $userService, User $user, TopicService $topicService, Article $article, QueryBuilder $queryBuilder, CacheService $cacheService, EventDispatcher $dispatcher)
{
$container->get('em')->willReturn($entityManager);
$container->get('session')->willReturn($session);
$container->get('request')->willReturn($request);
$container->get('translator')->willReturn($translator);
$container->get('form.factory')->willReturn($formFactory);
$container->get('form.csrf_provider')->willReturn($csrfTokenManagerAdapter);
$container->get('newscoop.cache')->willReturn($cacheService);
$container->get('user')->willReturn($userService);
$container->get('dispatcher')->willReturn($dispatcher);
$userService->getCurrentUser()->willReturn($user);
$container->get('newscoop_newscoop.topic_service')->willReturn($topicService);
$formBuilder->getForm(Argument::cetera())->willReturn($form);
$formFactory->create(Argument::cetera())->willReturn($form);
$form->createView()->willReturn($formView);
$form->handleRequest(Argument::cetera())->willReturn(true);
$form->isValid()->willReturn(true);
$entityManager->persist(Argument::any())->willReturn(true);
$entityManager->flush(Argument::any())->willReturn(true);
$entityManager->remove(Argument::any())->willReturn(true);
$entityManager->getRepository('Newscoop\\NewscoopBundle\\Entity\\Topic')->willReturn($repository);
$entityManager->getRepository('Newscoop\\Entity\\ArticleTopic')->willReturn($articleTopicrepository);
$this->setContainer($container);
$this->token = 'uTxRiEkont4XxRpTcSADPCowge7TgNONE7Y5HWd4pmY';
$request->get('_csrf_token')->willReturn($this->token);
$request->get('_code')->willReturn('en');
$request->get('_articleNumber')->willReturn('64');
$request->getLocale()->willReturn('en');
$request->get('_code', 'en')->willReturn('en');
$request->request = $parameterBag;
}
示例3: buildPager
/**
* {@inheritdoc}
*/
public function buildPager()
{
if ($this->bound) {
return;
}
foreach ($this->getFilters() as $name => $filter) {
list($type, $options) = $filter->getRenderSettings();
$this->formBuilder->add($filter->getFormName(), $type, $options);
}
$this->formBuilder->add('_sort_by', 'hidden');
$this->formBuilder->add('_sort_order', 'hidden');
$this->formBuilder->add('_page', 'hidden');
$this->formBuilder->add('_per_page', 'hidden');
$this->form = $this->formBuilder->getForm();
$this->form->submit($this->values);
$data = $this->form->getData();
foreach ($this->getFilters() as $name => $filter) {
$this->values[$name] = isset($this->values[$name]) ? $this->values[$name] : null;
$filter->apply($this->query, $data[$filter->getFormName()]);
}
if (isset($this->values['_sort_by'])) {
$this->query->setSortBy($this->values['_sort_by']);
$this->query->setSortOrder(isset($this->values['_sort_order']) ? $this->values['_sort_order'] : null);
}
$this->pager->setMaxPerPage(isset($this->values['_per_page']) ? $this->values['_per_page'] : 25);
$this->pager->setPage(isset($this->values['_page']) ? $this->values['_page'] : 1);
$this->pager->setQuery($this->query);
$this->pager->init();
$this->bound = true;
}
示例4: testFixCheckbox
/**
* @dataProvider valuesProvider
*/
public function testFixCheckbox($data, $expected, $suscriber, $transformer)
{
$dispatcher = new EventDispatcher();
if ($suscriber) {
$dispatcher->addSubscriber($suscriber);
}
$formFactory = Forms::createFormFactoryBuilder()->addExtensions(array())->getFormFactory();
$formBuilder = new FormBuilder('checkbox', 'stdClass', $dispatcher, $formFactory);
if ($transformer) {
$formBuilder->addViewTransformer($transformer);
}
$form = $formBuilder->getForm();
$form->submit($data);
$this->assertEquals($expected, $form->getData());
}
示例5: array
function it_builds_prototypes_forms_for_calculators($calculatorRegistry, FormBuilder $builder, FormBuilder $flatRateFormBuilder, Form $flatRateForm, FlatRateCalculator $flatRateCalculator, FormBuilder $perItemFormBuilder, Form $perItemForm, PerItemRateCalculator $perItemRateCalculator)
{
$builder->add(Argument::any(), Argument::cetera())->willReturn($builder);
$builder->addEventSubscriber(Argument::any())->willReturn($builder);
$flatRateCalculator->getConfigurationFormType()->willReturn('sylius_shipping_calculator_flat_rate_configuration');
$flatRateCalculator->isConfigurable()->willReturn(true);
$perItemRateCalculator->getConfigurationFormType()->willReturn('sylius_shipping_calculator_per_item_rate_configuration');
$perItemRateCalculator->isConfigurable()->willReturn(true);
$calculatorRegistry->getCalculators()->willReturn(array('flat_rate' => $flatRateCalculator, 'per_item_rate' => $perItemRateCalculator));
$flatRateFormBuilder->getForm()->willReturn($flatRateForm);
$builder->create('configuration', 'sylius_shipping_calculator_flat_rate_configuration')->willReturn($flatRateFormBuilder);
$perItemFormBuilder->getForm()->willReturn($perItemForm);
$builder->create('configuration', 'sylius_shipping_calculator_per_item_rate_configuration')->willReturn($perItemFormBuilder);
$builder->setAttribute('prototypes', array('calculators' => array('flat_rate' => $flatRateForm, 'per_item_rate' => $perItemForm), 'rules' => array()))->shouldBeCalled();
$this->buildForm($builder, array());
}
示例6:
function it_builds_prototypes_forms_for_calculators(ServiceRegistryInterface $calculatorRegistry, FormBuilder $builder, FormBuilder $flatRateFormBuilder, Form $flatRateForm, CalculatorInterface $flatRateCalculator, FormBuilder $perUnitFormBuilder, Form $perUnitForm, CalculatorInterface $perUnitRateCalculator, FormRegistryInterface $formRegistry)
{
$builder->add(Argument::any(), Argument::cetera())->willReturn($builder);
$builder->addEventSubscriber(Argument::any())->willReturn($builder);
$flatRateCalculator->getType()->willReturn('flat_rate');
$perUnitRateCalculator->getType()->willReturn('per_unit_rate');
$calculatorRegistry->all()->willReturn(['flat_rate' => $flatRateCalculator, 'per_unit_rate' => $perUnitRateCalculator]);
$flatRateFormBuilder->getForm()->willReturn($flatRateForm);
$builder->create('configuration', 'sylius_shipping_calculator_flat_rate')->willReturn($flatRateFormBuilder);
$perUnitFormBuilder->getForm()->willReturn($perUnitForm);
$builder->create('configuration', 'sylius_shipping_calculator_per_unit_rate')->willReturn($perUnitFormBuilder);
$formRegistry->hasType('sylius_shipping_calculator_per_unit_rate')->shouldBeCalled()->willReturn(true);
$formRegistry->hasType('sylius_shipping_calculator_flat_rate')->shouldBeCalled()->willReturn(true);
$builder->setAttribute('prototypes', ['calculators' => ['flat_rate' => $flatRateForm, 'per_unit_rate' => $perUnitForm], 'rules' => []])->shouldBeCalled();
$this->buildForm($builder, []);
}
示例7: let
function let(Container $container, Registry $doctrine, ArticleRepository $articleRepository, EntityManager $entityManager, Request $request, FormFactory $formFactory, FormBuilder $formBuilder, Form $form, FormView $formView, Router $router, EditorialCommentsService $editorialCommentService, EditorialComment $editorialComment, EditorialCommentRepository $editorialCommentRepository, User $user, UserService $userService, Article $article, AbstractQuery $query)
{
$container->get('em')->willReturn($entityManager);
$container->get('form.factory')->willReturn($formFactory);
$container->get('request')->willReturn($request);
$container->get('router')->willReturn($router);
$container->get('newscoop.editorial_comments')->willReturn($editorialCommentService);
$container->get('user')->willReturn($userService);
$formBuilder->getForm(Argument::cetera())->willReturn($form);
$formFactory->create(Argument::cetera())->willReturn($form);
$form->createView()->willReturn($formView);
$form->handleRequest(Argument::cetera())->willReturn(true);
$form->isValid()->willReturn(true);
$userService->getCurrentUser()->willReturn($user);
$entityManager->getRepository('Newscoop\\ArticlesBundle\\Entity\\EditorialComment')->willReturn($editorialCommentRepository);
$entityManager->getRepository('Newscoop\\Entity\\Article')->willReturn($articleRepository);
$articleRepository->getArticle(Argument::cetera())->willReturn($query);
$editorialCommentService->create(Argument::cetera())->willReturn($editorialComment);
$editorialCommentService->edit(Argument::cetera())->willReturn($editorialComment);
$editorialCommentService->resolve(Argument::type('\\Newscoop\\ArticlesBundle\\Entity\\EditorialComment'), Argument::type('\\Newscoop\\Entity\\User'), Argument::type('bool'))->willReturn($editorialComment);
$editorialCommentService->remove(Argument::type('\\Newscoop\\ArticlesBundle\\Entity\\EditorialComment'), Argument::type('\\Newscoop\\Entity\\User'))->willReturn(true);
$this->setContainer($container);
}
示例8: createForm
private function createForm($name)
{
$builder = new FormBuilder($name, null, $this->dispatcher, $this->factory);
$builder->setCompound(true);
$builder->setDataMapper($this->dataMapper);
return $builder->getForm();
}
示例9: buildForm
public function buildForm(FormBuilder $builder, array $options)
{
$this->key = $builder->getForm()->getName();
$builder->addValidator(new CaptchaValidator($this->session, $this->key));
}
示例10: buildForm
public function buildForm(FormBuilder $builder, array $options)
{
$builder->add('title')->add('pictures', 'file', array('attr' => array('multiple' => ''), "required" => FALSE));
$builder->getForm()->createView()->getChild('pictures')->set('full_name', $this->getName() . '[pictures][]');
}