-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[Form] fix "prototype" not required when parent form is not required #18317
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
Conversation
HeahDude
commented
Mar 26, 2016
Q | A |
---|---|
Branch? | 2.3+ |
Bug fix? | yes |
New feature? | no |
BC breaks? | no |
Deprecations? | no |
Tests pass? | yes |
Fixed tickets | #18311 |
License | MIT |
Doc PR | ~ |
7ee5392
to
e8e5682
Compare
|
||
if ($view->parent && !$view->parent->vars['required']) { | ||
$view->vars['prototype']->vars['required'] = false; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
May be a better solution:
$prototype = $form->getConfig()->getAttribute('prototype');
$view->vars['prototype'] = $prototype->setParent($form)->createView($view);
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed! Thanks @sergeyfedotov
@sergeyfedotov The assertion in your last test looks wrong, "prototype" should not be required in that case, and the test is passing while it's not as expected. I don't think there is a BC break here. |
Ok. I really don't know should it be interpreted as a BC break or not. But currently |
Seems like this line https://github.com/HeahDude/symfony/blob/bug-prototype_required/src/Symfony/Component/Form/Extension/Core/Type/CollectionType.php#L31 is not needed anymore. |
@sergeyfedotov Yes it is, if the parent does not override the prototype options, |
e8e5682
to
041c804
Compare
041c804
to
7df9ca2
Compare
Status: Ready |
👍 Status: Reviewed |
Note to the merger: in 2.8 |
Thank you @HeahDude. |
…t required (HeahDude) This PR was merged into the 2.3 branch. Discussion ---------- [Form] fix "prototype" not required when parent form is not required | Q | A | ------------- | --- | Branch? | 2.3+ | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | #18311 | License | MIT | Doc PR | ~ Commits ------- 7df9ca2 [Form] fix "prototype" not required when parent form is not required
This PR was merged into the 2.3 branch. Discussion ---------- [Form] Remove unnecessary option assignment | Q | A | ------------- | --- | Branch? | 2.3 | Bug fix? | no | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | - | License | MIT | Doc PR | - Option assignment is not required because the prototype inherits this option from the parent form via standard inheritance mechanism. Related pull requests: #16959, #18317 Commits ------- da8a197 Remove unnecessary option assignment