Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 8234f2a

Browse filesBrowse files
committed
#17580 compound forms without children should be considered rendered
implicitly
1 parent da6c664 commit 8234f2a
Copy full SHA for 8234f2a

File tree

2 files changed

+61
-6
lines changed
Filter options

2 files changed

+61
-6
lines changed

‎src/Symfony/Component/Form/FormView.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Form/FormView.php
+6-2Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,12 @@ public function __construct(FormView $parent = null)
6565
*/
6666
public function isRendered()
6767
{
68-
if (true === $this->rendered || 0 === count($this->children)) {
69-
return $this->rendered;
68+
if ($this->rendered) {
69+
return true;
70+
}
71+
72+
if (isset($this->vars['compound']) ? !$this->vars['compound'] : 0 === count($this->children)) {
73+
return false;
7074
}
7175

7276
foreach ($this->children as $child) {

‎src/Symfony/Component/Form/Tests/Extension/Core/Type/FormTypeTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Form/Tests/Extension/Core/Type/FormTypeTest.php
+55-4Lines changed: 55 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -488,16 +488,67 @@ public function testPassMultipartTrueIfAnyChildIsMultipartToView()
488488
$this->assertTrue($view->vars['multipart']);
489489
}
490490

491-
public function testViewIsNotRenderedByDefault()
491+
public function testViewIsConsideredRenderedForRenderedNonCompoundForms()
492+
{
493+
$view = $this->factory->createBuilder('form', null, array(
494+
'compound' => false,
495+
))
496+
->getForm()
497+
->createView();
498+
499+
$view->setRendered();
500+
501+
$this->assertTrue($view->isRendered());
502+
}
503+
504+
public function testViewIsNotConsideredRenderedImplicitlyForNonCompoundForms()
505+
{
506+
$view = $this->factory->createBuilder('form', null, array(
507+
'compound' => false,
508+
))
509+
->getForm()
510+
->createView();
511+
512+
$this->assertFalse($view->isRendered());
513+
}
514+
515+
public function testViewIsNotConsideredRenderedImplicitlyForCompoundFormsWithNonCompoundChildren()
492516
{
493517
$view = $this->factory->createBuilder('form')
494-
->add('foo', 'form')
495-
->getForm()
496-
->createView();
518+
->add('foo', 'form', array(
519+
'compound' => false,
520+
))
521+
->getForm()
522+
->createView();
497523

498524
$this->assertFalse($view->isRendered());
499525
}
500526

527+
public function testViewIsConsideredRenderedImplicitlyForCompoundFormsWithRenderedNonCompoundChildren()
528+
{
529+
$view = $this->factory->createBuilder('form')
530+
->add('foo', 'form', array(
531+
'compound' => false,
532+
))
533+
->getForm()
534+
->createView();
535+
536+
foreach ($view as $child) {
537+
$child->setRendered();
538+
}
539+
540+
$this->assertTrue($view->isRendered());
541+
}
542+
543+
public function testViewIsConsideredRenderedImplicitlyForCompoundFormsWithoutChildren()
544+
{
545+
$view = $this->factory->createBuilder('form')
546+
->getForm()
547+
->createView();
548+
549+
$this->assertTrue($view->isRendered());
550+
}
551+
501552
public function testErrorBubblingIfCompound()
502553
{
503554
$form = $this->factory->create('form', null, array(

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.