Skip to content

[Form] compound forms without children should be considered rendered implicitly #20108

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from

Conversation

backbone87
Copy link
Contributor

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

second try, obsoletes #20080

@backbone87
Copy link
Contributor Author

hm somehow the first commit from #20080 is missing here?

@linaori
Copy link
Contributor

linaori commented Sep 30, 2016

Could be related to the revert?

@backbone87
Copy link
Contributor Author

yes but how do i get it back, do i need to make a new commit or can this just be merged manually via cherrypicking?

@HeahDude
Copy link
Contributor

try to amend it to change its hash

@backbone87
Copy link
Contributor Author

have rebased it onto current 2.7 and collapsed both commits

@backbone87
Copy link
Contributor Author

@fabpot you have added this bugfix to the 2.7.19 tag, though you reverted the first PR, pls check this one, as the failing test cases are fixed, maybe @webmozart should also review this

@HeahDude
Copy link
Contributor

HeahDude commented Oct 3, 2016

@backbone87 since you modify abstract tests of the Form component, you have to update both TwigBridge and FrameworkBundle dependency to it in their composer.json to ~2.7.20|~2.8.13|~3.1.6.

Be sure to run tests on them before pushing, thanks.

@HeahDude
Copy link
Contributor

HeahDude commented Oct 4, 2016

OK, I confirm tests are green.

Status: Reviewed

@@ -453,7 +453,7 @@ public function testNestedFormError()
$form = $this->factory->createNamedBuilder('name', 'form')
->add($this->factory
->createNamedBuilder('child', 'form', null, array('error_bubbling' => false))
->add('grandChild', 'form')
->add('grandChild', 'text')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why this change?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

$form->createView()->isRendered() now returns true, when the whole form tree is compound and would result in this test case failing.

The real change is for $grandChild->createView()->isRendered() which now returns true in case grandChild is compound. This is because compound forms with no children are considered rendered now, where before each leaf form view (that includes compound forms without children), that doesnt have its rendered flag explicitly set, would not be considered rendered.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok it was reverted when I tried on master because of the conflict resolution. So I think you should not make that change and fix the layout test in this case because it does impact form_rest and this should be tested too.

@backbone87
Copy link
Contributor Author

i would still recommend to wait for a review of @webmozart

consider the following usecase:

$form = $factory->create(FormType::class, [ 'items' => [] ]);
$form->add('items', CollectionType::class, [ 'entry_type' => TextType::class ]);

and the following tpl:

{{ form_start(form) }}
  {{ form_errors(form) }}
  {{ form_row(form.items) }}
{{ form_end(form) }}

with this change {{ form_row(form.items) }} will not output anything, because form.items.rendered is true and https://github.com/symfony/symfony/blob/master/src/Symfony/Component/Form/FormRenderer.php#L158 prevents rendering of form views, that are already rendered (either explicitly or implicitly). I dont think the behavior of the renderer is good in this case. If i request form.items to be rendered explicitly, i dont want the renderer to deny that because of some internal state.

also see #20080 (comment) for more

@HeahDude
Copy link
Contributor

HeahDude commented Oct 4, 2016

Status: Needs Work

@HeahDude
Copy link
Contributor

HeahDude commented Oct 4, 2016

Sorry I've got the message with delay, yes the choice type is definitely a problem, let's solve this with #17609 instead.

@nicolas-grekas nicolas-grekas added this to the 2.7 milestone Dec 6, 2016
@nicolas-grekas
Copy link
Member

@backbone87 @HeahDude what's the status here? (rebase needed)

@fabpot
Copy link
Member

fabpot commented Mar 31, 2018

Closing as there is no more activity.

@fabpot fabpot closed this Mar 31, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants