Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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 -%}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,18 @@ public function testStartTagHasNoActionAttributeWhenActionIsEmpty()
$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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,18 @@ public function testStartTagHasNoActionAttributeWhenActionIsEmpty()
$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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,18 @@ public function testStartTagHasNoActionAttributeWhenActionIsEmpty()
$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);
Expand Down
Original file line number Diff line number Diff line change
@@ -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 ?>
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,18 @@ public function testStartTagHasNoActionAttributeWhenActionIsEmpty()
$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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,18 @@ public function testStartTagHasNoActionAttributeWhenActionIsEmpty()
$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
Expand Down