merged branch bschussek/issue2308 (PR #3320)
Commits
-------
0a4519d
[Form] Fixed duplicate errors on forms with "error_bubbling"=false
Discussion
----------
[Form] Fixed duplicate errors on forms with "error_bubbling"=false
Bug fix: yes
Feature addition: no
Backwards compatibility break: no
Symfony2 tests pass: yes
Fixes the following tickets: #2308
Todo: -
![Travis Build Status](https://secure.travis-ci.org/bschussek/symfony.png?branch=issue2308)
This commit is contained in:
commit
c614be74c8
@ -233,6 +233,15 @@
|
|||||||
{% endspaceless %}
|
{% endspaceless %}
|
||||||
{% endblock field_row %}
|
{% endblock field_row %}
|
||||||
|
|
||||||
|
{% block form_row %}
|
||||||
|
{% spaceless %}
|
||||||
|
<div>
|
||||||
|
{{ form_label(form, label|default(null)) }}
|
||||||
|
{{ form_widget(form) }}
|
||||||
|
</div>
|
||||||
|
{% endspaceless %}
|
||||||
|
{% endblock form_row %}
|
||||||
|
|
||||||
{% block hidden_row %}
|
{% block hidden_row %}
|
||||||
{{ form_widget(form) }}
|
{{ form_widget(form) }}
|
||||||
{% endblock hidden_row %}
|
{% endblock hidden_row %}
|
||||||
|
@ -14,6 +14,19 @@
|
|||||||
{% endspaceless %}
|
{% endspaceless %}
|
||||||
{% endblock field_row %}
|
{% endblock field_row %}
|
||||||
|
|
||||||
|
{% block form_row %}
|
||||||
|
{% spaceless %}
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
{{ form_label(form, label|default(null)) }}
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
{{ form_widget(form) }}
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
{% endspaceless %}
|
||||||
|
{% endblock form_row %}
|
||||||
|
|
||||||
{% block form_errors %}
|
{% block form_errors %}
|
||||||
{% spaceless %}
|
{% spaceless %}
|
||||||
{% if errors|length > 0 %}
|
{% if errors|length > 0 %}
|
||||||
|
@ -0,0 +1,4 @@
|
|||||||
|
<div>
|
||||||
|
<?php echo $view['form']->label($form, isset($label) ? $label : null) ?>
|
||||||
|
<?php echo $view['form']->widget($form) ?>
|
||||||
|
</div>
|
@ -0,0 +1,8 @@
|
|||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
<?php echo $view['form']->label($form, isset($label) ? $label : null) ?>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<?php echo $view['form']->widget($form) ?>
|
||||||
|
</td>
|
||||||
|
</tr>
|
@ -344,6 +344,25 @@ abstract class AbstractDivLayoutTest extends AbstractLayoutTest
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// https://github.com/symfony/symfony/issues/2308
|
||||||
|
public function testNestedFormError()
|
||||||
|
{
|
||||||
|
$form = $this->factory->createNamedBuilder('form', 'name')
|
||||||
|
->add('child', 'form', array('error_bubbling' => false))
|
||||||
|
->getForm();
|
||||||
|
|
||||||
|
$form->get('child')->addError(new FormError('Error!'));
|
||||||
|
|
||||||
|
$this->assertWidgetMatchesXpath($form->createView(), array(),
|
||||||
|
'/div
|
||||||
|
[
|
||||||
|
./div/div[@id="name_child"][./ul/li[.="[trans]Error![/trans]"]]
|
||||||
|
]
|
||||||
|
[count(.//li[.="[trans]Error![/trans]"])=1]
|
||||||
|
'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
public function testRepeated()
|
public function testRepeated()
|
||||||
{
|
{
|
||||||
$form = $this->factory->createNamed('repeated', 'name', 'foobar', array(
|
$form = $this->factory->createNamed('repeated', 'name', 'foobar', array(
|
||||||
|
@ -196,6 +196,27 @@ abstract class AbstractTableLayoutTest extends AbstractLayoutTest
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// https://github.com/symfony/symfony/issues/2308
|
||||||
|
public function testNestedFormError()
|
||||||
|
{
|
||||||
|
$form = $this->factory->createNamedBuilder('form', 'name')
|
||||||
|
->add('child', 'form', array('error_bubbling' => false))
|
||||||
|
->getForm();
|
||||||
|
|
||||||
|
$form->get('child')->addError(new FormError('Error!'));
|
||||||
|
|
||||||
|
$this->assertWidgetMatchesXpath($form->createView(), array(),
|
||||||
|
'/table
|
||||||
|
[
|
||||||
|
./tr/td/table
|
||||||
|
[@id="name_child"]
|
||||||
|
[./tr/td/ul/li[.="[trans]Error![/trans]"]]
|
||||||
|
]
|
||||||
|
[count(.//li[.="[trans]Error![/trans]"])=1]
|
||||||
|
'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
public function testRepeated()
|
public function testRepeated()
|
||||||
{
|
{
|
||||||
$form = $this->factory->createNamed('repeated', 'name', 'foobar', array(
|
$form = $this->factory->createNamed('repeated', 'name', 'foobar', array(
|
||||||
|
Reference in New Issue
Block a user