Skip to content

Commit 54c63fa

Browse files
committed
fix test for not configured form action attribute
1 parent dbb099d commit 54c63fa

File tree

7 files changed

+62
-2
lines changed

7 files changed

+62
-2
lines changed

src/Symfony/Bridge/Twig/Resources/views/Form/form_div_layout.html.twig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,7 @@
274274
{%- else -%}
275275
{% set form_method = "POST" %}
276276
{%- endif -%}
277-
<form name="{{ name }}" method="{{ form_method|lower }}"{% if action %} action="{{ action }}"{% endif %}{% for attrname, attrvalue in attr %} {{ attrname }}="{{ attrvalue }}"{% endfor %}{% if multipart %} enctype="multipart/form-data"{% endif %}>
277+
<form name="{{ name }}" method="{{ form_method|lower }}"{% if action != '' %} action="{{ action }}"{% endif %}{% for attrname, attrvalue in attr %} {{ attrname }}="{{ attrvalue }}"{% endfor %}{% if multipart %} enctype="multipart/form-data"{% endif %}>
278278
{%- if form_method != method -%}
279279
<input type="hidden" name="_method" value="{{ method }}" />
280280
{%- endif -%}

src/Symfony/Bridge/Twig/Tests/Extension/FormExtensionBootstrap3LayoutTest.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,18 @@ public function testStartTagHasNoActionAttributeWhenActionIsEmpty()
7474
$this->assertSame('<form name="form" method="get">', $html);
7575
}
7676

77+
public function testStartTagHasActionAttributeWhenActionIsZero()
78+
{
79+
$form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\FormType', null, array(
80+
'method' => 'get',
81+
'action' => '0',
82+
));
83+
84+
$html = $this->renderStart($form->createView());
85+
86+
$this->assertSame('<form name="form" method="get" action="0">', $html);
87+
}
88+
7789
protected function renderForm(FormView $view, array $vars = array())
7890
{
7991
return (string) $this->extension->renderer->renderBlock($view, 'form', $vars);

src/Symfony/Bridge/Twig/Tests/Extension/FormExtensionDivLayoutTest.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,18 @@ public function testStartTagHasNoActionAttributeWhenActionIsEmpty()
153153
$this->assertSame('<form name="form" method="get">', $html);
154154
}
155155

156+
public function testStartTagHasActionAttributeWhenActionIsZero()
157+
{
158+
$form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\FormType', null, array(
159+
'method' => 'get',
160+
'action' => '0',
161+
));
162+
163+
$html = $this->renderStart($form->createView());
164+
165+
$this->assertSame('<form name="form" method="get" action="0">', $html);
166+
}
167+
156168
protected function renderForm(FormView $view, array $vars = array())
157169
{
158170
return (string) $this->extension->renderer->renderBlock($view, 'form', $vars);

src/Symfony/Bridge/Twig/Tests/Extension/FormExtensionTableLayoutTest.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,18 @@ public function testStartTagHasNoActionAttributeWhenActionIsEmpty()
7575
$this->assertSame('<form name="form" method="get">', $html);
7676
}
7777

78+
public function testStartTagHasActionAttributeWhenActionIsZero()
79+
{
80+
$form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\FormType', null, array(
81+
'method' => 'get',
82+
'action' => '0',
83+
));
84+
85+
$html = $this->renderStart($form->createView());
86+
87+
$this->assertSame('<form name="form" method="get" action="0">', $html);
88+
}
89+
7890
protected function renderForm(FormView $view, array $vars = array())
7991
{
8092
return (string) $this->extension->renderer->renderBlock($view, 'form', $vars);
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php $method = strtoupper($method) ?>
22
<?php $form_method = $method === 'GET' || $method === 'POST' ? $method : 'POST' ?>
3-
<form name="<?php echo $name ?>" method="<?php echo strtolower($form_method) ?>"<?php if ($action): ?> action="<?php echo $action ?>"<?php endif ?><?php foreach ($attr as $k => $v) { printf(' %s="%s"', $view->escape($k), $view->escape($v)); } ?><?php if ($multipart): ?> enctype="multipart/form-data"<?php endif ?>>
3+
<form name="<?php echo $name ?>" method="<?php echo strtolower($form_method) ?>"<?php if ($action !== ''): ?> action="<?php echo $action ?>"<?php endif ?><?php foreach ($attr as $k => $v) { printf(' %s="%s"', $view->escape($k), $view->escape($v)); } ?><?php if ($multipart): ?> enctype="multipart/form-data"<?php endif ?>>
44
<?php if ($form_method !== $method): ?>
55
<input type="hidden" name="_method" value="<?php echo $method ?>" />
66
<?php endif ?>

src/Symfony/Bundle/FrameworkBundle/Tests/Templating/Helper/FormHelperDivLayoutTest.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,18 @@ public function testStartTagHasNoActionAttributeWhenActionIsEmpty()
7373
$this->assertSame('<form name="form" method="get">', $html);
7474
}
7575

76+
public function testStartTagHasActionAttributeWhenActionIsZero()
77+
{
78+
$form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\FormType', null, array(
79+
'method' => 'get',
80+
'action' => '0',
81+
));
82+
83+
$html = $this->renderStart($form->createView());
84+
85+
$this->assertSame('<form name="form" method="get" action="0">', $html);
86+
}
87+
7688
protected function renderForm(FormView $view, array $vars = array())
7789
{
7890
return (string) $this->engine->get('form')->form($view, $vars);

src/Symfony/Bundle/FrameworkBundle/Tests/Templating/Helper/FormHelperTableLayoutTest.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,18 @@ public function testStartTagHasNoActionAttributeWhenActionIsEmpty()
4343
$this->assertSame('<form name="form" method="get">', $html);
4444
}
4545

46+
public function testStartTagHasActionAttributeWhenActionIsZero()
47+
{
48+
$form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\FormType', null, array(
49+
'method' => 'get',
50+
'action' => '0',
51+
));
52+
53+
$html = $this->renderStart($form->createView());
54+
55+
$this->assertSame('<form name="form" method="get" action="0">', $html);
56+
}
57+
4658
protected function getExtensions()
4759
{
4860
// should be moved to the Form component once absolute file paths are supported

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy