bug #20080 [Form] compound forms without children should be considered rendered implicitly (backbone87)
This PR was merged into the 2.7 branch.
Discussion
----------
[Form] compound forms without children should be considered rendered implicitly
| Q | A
| ------------- | ---
| Branch? | 2.7
| Bug fix? | yes
| New feature? | no
| BC breaks? | possibly
| Deprecations? | no
| Tests pass? | yes
| Fixed tickets | #17580
| License | MIT
| Doc PR | n/a
Commits
-------
8234f2a
#17580 compound forms without children should be considered rendered implicitly
This commit is contained in:
commit
eae5a9ba0b
@ -65,8 +65,12 @@ class FormView implements \ArrayAccess, \IteratorAggregate, \Countable
|
|||||||
*/
|
*/
|
||||||
public function isRendered()
|
public function isRendered()
|
||||||
{
|
{
|
||||||
if (true === $this->rendered || 0 === count($this->children)) {
|
if ($this->rendered) {
|
||||||
return $this->rendered;
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isset($this->vars['compound']) ? !$this->vars['compound'] : 0 === count($this->children)) {
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ($this->children as $child) {
|
foreach ($this->children as $child) {
|
||||||
|
@ -488,16 +488,67 @@ class FormTypeTest extends BaseTypeTest
|
|||||||
$this->assertTrue($view->vars['multipart']);
|
$this->assertTrue($view->vars['multipart']);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testViewIsNotRenderedByDefault()
|
public function testViewIsConsideredRenderedForRenderedNonCompoundForms()
|
||||||
{
|
{
|
||||||
$view = $this->factory->createBuilder('form')
|
$view = $this->factory->createBuilder('form', null, array(
|
||||||
->add('foo', 'form')
|
'compound' => false,
|
||||||
->getForm()
|
))
|
||||||
->createView();
|
->getForm()
|
||||||
|
->createView();
|
||||||
|
|
||||||
|
$view->setRendered();
|
||||||
|
|
||||||
|
$this->assertTrue($view->isRendered());
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testViewIsNotConsideredRenderedImplicitlyForNonCompoundForms()
|
||||||
|
{
|
||||||
|
$view = $this->factory->createBuilder('form', null, array(
|
||||||
|
'compound' => false,
|
||||||
|
))
|
||||||
|
->getForm()
|
||||||
|
->createView();
|
||||||
|
|
||||||
$this->assertFalse($view->isRendered());
|
$this->assertFalse($view->isRendered());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testViewIsNotConsideredRenderedImplicitlyForCompoundFormsWithNonCompoundChildren()
|
||||||
|
{
|
||||||
|
$view = $this->factory->createBuilder('form')
|
||||||
|
->add('foo', 'form', array(
|
||||||
|
'compound' => false,
|
||||||
|
))
|
||||||
|
->getForm()
|
||||||
|
->createView();
|
||||||
|
|
||||||
|
$this->assertFalse($view->isRendered());
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testViewIsConsideredRenderedImplicitlyForCompoundFormsWithRenderedNonCompoundChildren()
|
||||||
|
{
|
||||||
|
$view = $this->factory->createBuilder('form')
|
||||||
|
->add('foo', 'form', array(
|
||||||
|
'compound' => false,
|
||||||
|
))
|
||||||
|
->getForm()
|
||||||
|
->createView();
|
||||||
|
|
||||||
|
foreach ($view as $child) {
|
||||||
|
$child->setRendered();
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->assertTrue($view->isRendered());
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testViewIsConsideredRenderedImplicitlyForCompoundFormsWithoutChildren()
|
||||||
|
{
|
||||||
|
$view = $this->factory->createBuilder('form')
|
||||||
|
->getForm()
|
||||||
|
->createView();
|
||||||
|
|
||||||
|
$this->assertTrue($view->isRendered());
|
||||||
|
}
|
||||||
|
|
||||||
public function testErrorBubblingIfCompound()
|
public function testErrorBubblingIfCompound()
|
||||||
{
|
{
|
||||||
$form = $this->factory->create('form', null, array(
|
$form = $this->factory->create('form', null, array(
|
||||||
|
Reference in New Issue
Block a user