minor #16034 fix test for not configured form action attribute (xabbuh)
This PR was merged into the 2.8 branch.
Discussion
----------
fix test for not configured form action attribute
| Q | A
| ------------- | ---
| Bug fix? | yes
| New feature? | no
| BC breaks? | no
| Deprecations? | no
| Tests pass? | yes
| Fixed tickets | #16029
| License | MIT
| Doc PR |
As @Tobion noted in https://github.com/symfony/symfony/pull/16029#discussion_r40851757 `0` is a valid relative path that can be used for the form action.
Commits
-------
54c63fa
fix test for not configured form action attribute
This commit is contained in:
commit
08c5b3f83c
@ -274,7 +274,7 @@
|
||||
{%- else -%}
|
||||
{% set form_method = "POST" %}
|
||||
{%- endif -%}
|
||||
<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 %}>
|
||||
<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 %}>
|
||||
{%- if form_method != method -%}
|
||||
<input type="hidden" name="_method" value="{{ method }}" />
|
||||
{%- endif -%}
|
||||
|
@ -74,6 +74,18 @@ class FormExtensionBootstrap3LayoutTest extends AbstractBootstrap3LayoutTest
|
||||
$this->assertSame('<form name="form" method="get">', $html);
|
||||
}
|
||||
|
||||
public function testStartTagHasActionAttributeWhenActionIsZero()
|
||||
{
|
||||
$form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\FormType', null, array(
|
||||
'method' => 'get',
|
||||
'action' => '0',
|
||||
));
|
||||
|
||||
$html = $this->renderStart($form->createView());
|
||||
|
||||
$this->assertSame('<form name="form" method="get" action="0">', $html);
|
||||
}
|
||||
|
||||
protected function renderForm(FormView $view, array $vars = array())
|
||||
{
|
||||
return (string) $this->extension->renderer->renderBlock($view, 'form', $vars);
|
||||
|
@ -153,6 +153,18 @@ class FormExtensionDivLayoutTest extends AbstractDivLayoutTest
|
||||
$this->assertSame('<form name="form" method="get">', $html);
|
||||
}
|
||||
|
||||
public function testStartTagHasActionAttributeWhenActionIsZero()
|
||||
{
|
||||
$form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\FormType', null, array(
|
||||
'method' => 'get',
|
||||
'action' => '0',
|
||||
));
|
||||
|
||||
$html = $this->renderStart($form->createView());
|
||||
|
||||
$this->assertSame('<form name="form" method="get" action="0">', $html);
|
||||
}
|
||||
|
||||
protected function renderForm(FormView $view, array $vars = array())
|
||||
{
|
||||
return (string) $this->extension->renderer->renderBlock($view, 'form', $vars);
|
||||
|
@ -75,6 +75,18 @@ class FormExtensionTableLayoutTest extends AbstractTableLayoutTest
|
||||
$this->assertSame('<form name="form" method="get">', $html);
|
||||
}
|
||||
|
||||
public function testStartTagHasActionAttributeWhenActionIsZero()
|
||||
{
|
||||
$form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\FormType', null, array(
|
||||
'method' => 'get',
|
||||
'action' => '0',
|
||||
));
|
||||
|
||||
$html = $this->renderStart($form->createView());
|
||||
|
||||
$this->assertSame('<form name="form" method="get" action="0">', $html);
|
||||
}
|
||||
|
||||
protected function renderForm(FormView $view, array $vars = array())
|
||||
{
|
||||
return (string) $this->extension->renderer->renderBlock($view, 'form', $vars);
|
||||
|
@ -1,6 +1,6 @@
|
||||
<?php $method = strtoupper($method) ?>
|
||||
<?php $form_method = $method === 'GET' || $method === 'POST' ? $method : 'POST' ?>
|
||||
<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 ?>>
|
||||
<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 ?>>
|
||||
<?php if ($form_method !== $method): ?>
|
||||
<input type="hidden" name="_method" value="<?php echo $method ?>" />
|
||||
<?php endif ?>
|
||||
|
@ -73,6 +73,18 @@ class FormHelperDivLayoutTest extends AbstractDivLayoutTest
|
||||
$this->assertSame('<form name="form" method="get">', $html);
|
||||
}
|
||||
|
||||
public function testStartTagHasActionAttributeWhenActionIsZero()
|
||||
{
|
||||
$form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\FormType', null, array(
|
||||
'method' => 'get',
|
||||
'action' => '0',
|
||||
));
|
||||
|
||||
$html = $this->renderStart($form->createView());
|
||||
|
||||
$this->assertSame('<form name="form" method="get" action="0">', $html);
|
||||
}
|
||||
|
||||
protected function renderForm(FormView $view, array $vars = array())
|
||||
{
|
||||
return (string) $this->engine->get('form')->form($view, $vars);
|
||||
|
@ -43,6 +43,18 @@ class FormHelperTableLayoutTest extends AbstractTableLayoutTest
|
||||
$this->assertSame('<form name="form" method="get">', $html);
|
||||
}
|
||||
|
||||
public function testStartTagHasActionAttributeWhenActionIsZero()
|
||||
{
|
||||
$form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\FormType', null, array(
|
||||
'method' => 'get',
|
||||
'action' => '0',
|
||||
));
|
||||
|
||||
$html = $this->renderStart($form->createView());
|
||||
|
||||
$this->assertSame('<form name="form" method="get" action="0">', $html);
|
||||
}
|
||||
|
||||
protected function getExtensions()
|
||||
{
|
||||
// should be moved to the Form component once absolute file paths are supported
|
||||
|
Reference in New Issue
Block a user