Skip to content

[Form] Documentation of Collection Type #3443

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
peterrehm opened this issue Jan 8, 2014 · 6 comments
Closed

[Form] Documentation of Collection Type #3443

peterrehm opened this issue Jan 8, 2014 · 6 comments
Labels
actionable Clear and specific issues ready for anyone to take them. Form good first issue Ideal for your first contribution! (some Symfony experience may be required)

Comments

@peterrehm
Copy link
Contributor

As mentioned by @stof in symfony/symfony#9973 there is a performance impact by using a new form type as collection type. It is recommended to use a registered service as form type to take advantage of the performance improvements introduced with Symfony 2.1 (symfony/symfony#4882).

This should be verified and the collection documentation with the corresponding cookbook (embedding collections) should be updated with the recommended way.

@peterrehm
Copy link
Contributor Author

@stof If I read this correctly:

+  * The method `createBuilder` was removed from `FormTypeInterface` for performance
 +    reasons. It is now not possible anymore to use custom implementations of
 +    `FormBuilderInterface` for specific form types.

This is not regarding ne MyClassType(), it is regarding custom implementations with createBuilder()
as you can use in the Controller. Or am I wrong?

@wouterj
Copy link
Member

wouterj commented Jan 8, 2014

Or am I wrong?

Yes, you're wrong. The createBuilder method from the controller is in the Controller class, this is about FormTypeInterface::createBuilder, something you could only use in Symfony 2.0. For instance, this method was used in the FormType.

@wouterj
Copy link
Member

wouterj commented Jan 8, 2014

For the reference, this issue is talking about "Allowing "new" tags with the "prototype"" of the /cookbook/form/form_collections article. This should be updated: The example should be changed (you can see an example of that in the first issue mentioned above).

A .. caution:: should also be added in the collection field type reference.

@peterrehm
Copy link
Contributor Author

I just wanted to verify if it actually a performance impact as it is described. If it is so it should be addressed.

@stof
Copy link
Member

stof commented Jan 9, 2014

There is a performance impact. Whe you pass a type instance to the FormBuilder::add() method, it registers it in the form registry, which requires resolving the inheritance tree for this type. If you register it again, it requries resolving again, while Symfony 2.1 optimizes the resolution to be done only when registering the type rather than each time you use it.
for a the inner type of collection field, this has a major impact, as the type will be used for each item of the collection.

@peterrehm
Copy link
Contributor Author

Closing it since as of 2.8 / 3.0 types will always be registered by the FQCN.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
actionable Clear and specific issues ready for anyone to take them. Form good first issue Ideal for your first contribution! (some Symfony experience may be required)
Projects
None yet
Development

No branches or pull requests

3 participants