-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[Form][2.8 and 3.0] Form type usage #16611
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
I believe the idea is that you should have one form type and then configure it in 4 different ways when you use it. Or, have 1 base class ( I don't know if this fully helps @rande - but this is a starting point. Obviously, we need SonataAdminBundle to be able to upgrade :) For reference: #15079. |
@weaverryan Thanks for your reply. Looks like there are a lot of thread about this. I still feel it is wrong: DX is bad, not OOP friendly, and this will not help to have support for SF2.7 and SF3.0 with the same bundle version. I am almost forced to create major version of sonata's bundles just for that (as far as I am with deprecated issues on 2.8). |
@rande I don't disagree (or necessarily agree, though I think this will be a big annoying upgrade problem for people). What's your approach then: create multiple sub-classes for each? Is that the BC break that you'll be introducing? |
@weaverryan I will create empty class for each type. 20 so far ... this will solve integration with 3.0. but I will still need to find a hack to not used the FCQN to avoid breaking tone of Admin instances ... |
@rande I think you can still register different instances of the same form type via DI just as before. The name must not be a real existing FQCN. This is just the case for most use-cases and all core form types (which avoids to force people invent names for But you can still do the same as before. Just register the form types with different names and then reference them in the factory. |
@Tobion not sure I understand your solution. With symfony3, you must have one class per type: https://github.com/symfony/symfony/blob/master/src/Symfony/Component/Form/FormRegistry.php#L109-L124. So the only solution is to create empty classes to the fqcn array will be populated properly. |
Hm I see. I think that is wrong. It should still use the |
For the record, the architectural form changes will not be altered/reverted. Update your application/bundles or use a mapping bundle (soon to be announced) to restore the feature. At least the Symfony Core team will not be in charge of that. |
I am working on Sonata Project migration to work on symfony2.8 and symfony3.0. I get an architectural issue with the new method signature for the
FormFactory
. The type must be a FQCN, the FQCN has one major drawback, you have a 1:1 relation between the type and the class/instance. With the previous signature you have a N:N relation between types and the class, ie you can have different types handled by the same class but with different instance configurations.With sf2.7,
The class behind the service is
Sonata\CoreBundle\Form\Type\DoctrineORMSerializationType
with different configurations per instance...With > SF2.8:
Of course, we are loosing definitions as the FQCN overlap keys. Is the best practice is to create a class per type ? If so we are loosing the benefit of OOP.
This change make very hard to have one bundle version working with Symfony 2.7, 2.8 and 3.0. And I don't see any benefit of it.
Can you explain or point to the valid PR which explain this choice?
The text was updated successfully, but these errors were encountered: