本文整理汇总了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, []);
}
示例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']);
}
示例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;
}
示例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);
}
示例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()));
}
示例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()];
}
示例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;
}
示例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;
}
示例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()];
}
示例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);
}
示例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, []);
}
示例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);
}
示例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);
}
示例14: getView
/**
* @return FormView
*/
public function getView()
{
if (!$this->view) {
$this->view = $this->form->createView();
$this->onCreateView($this->view, $this);
}
return $this->view;
}
示例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);
}