-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[Form] prototype "required" option is inconsistent with the default option #18311
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
Comments
Hi @sergeyfedotov, thanks for reporting this issue. It should have been fixed in #16959 as of 2.3.36, 2.7.8, 2.8.1 and 3.0.1 releases. Which version are you using ? |
It may be expected if the collection is required any entry will be too. |
@HeahDude I use Symfony 3.0.3 and I saw your PR. As far as I can see your fix only solves the issue with the option specified in the builder: public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder
->add('photos', CollectionType::class, [
'entry_type' => PhotoType::class
'required' => false
])
;
} But it does not solve the problem with the option specified as default. |
It seems expected to me since Am I missing something here ? |
Child forms inherit the non-required option from the parent form unlike the prototype. The forms existing in the collection are rendered without the required attribute and the prototype is rendered with the required attribute. This seems like inconsistent behavior |
This contradicts a tested behavior, see: It should be expected that So what looks inconsistent to me is that it actually does not happen for the child forms but only for the prototype (the opposite of your suggestion). |
I wrote two tests to demonstrate the expected behaviour: https://github.com/sergeyfedotov/symfony-form/commit/7b75c4775dd2f0dcaae470328f19958f055ded07 Both tests are now failed with the same assertion:
|
Ok thanks, I misunderstood your hierarchy. Would you like to work on a patch ? Otherwise I may look into it. |
See #18317 for a fix. |
…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
Seems like this issue is related to #15544
Actual result:
Prototype is rendered with the "required" option. The explanation of this behavior is given in the comment #15544 (comment)
Is it possible to fix it?
The text was updated successfully, but these errors were encountered: