-
-
Notifications
You must be signed in to change notification settings - Fork 5.2k
[Cookbook][Forms] Add how to generic form type extension #5154
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
[Cookbook][Forms] Add how to generic form type extension #5154
Conversation
@@ -129,6 +129,9 @@ The ``alias`` key of the tag is the type of field that this extension should | |||
be applied to. In your case, as you want to extend the ``file`` field type, | |||
you will use ``file`` as an alias. | |||
|
|||
If you want to create a generic feature, applied to all field types, simply |
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.
Shouldn't "generic feature" be "generic extension"?
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.
I followed the vocabulary used in the first section list which says
You want to add a generic feature to several types (such as adding a "help" text to every field type);
(original emphasis)
But if you still think extension would be a better word, I will be happy to amend my commit.
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.
Hmm, what about removing it completely:
If you want to apply the extension to all field types, you can specify
form
as alias and value returned bygetExtendedType()
.
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.
I liked to have the original vocabulary or at least the word "generic" to make it searchable. But I like your formulation too and its location in the page should be enough.
New commit on its way.
Thanks a lot! I've left one minor comment, but overall I like this addition, |
… appropriate doc (got it from reference/dic_tags.html#form-type-extension)
8365d36
to
1b83b95
Compare
Note that returning |
Then what would be the configuration to apply an extension to all types? If a code PR is required for this, I'm certainly ready to code and open one since I need the feature. Would you be interested by that? |
The PR to fix the code and restore the feature has been rejected. |
…nem) This PR was squashed before being merged into the 2.3 branch (closes #5227). Discussion ---------- [Cookbook] Fix doc on Generic Form Type Extensions | Q | A | ------------- | --- | Doc fix? | yes | New docs? | no | Applies to | >=2.3 | Fixed tickets | N/A Follow up on #5154 (Sorry the first one didn't use the PR Template BTW) and symfony/symfony#14456. I cleaned up the reference on DIC Tags, I think referring to the cookbook article prevents duplicating documentation (and taking the risk it will get out of date or inconsistent later on, as it did). Then I removed the mention of Generic FTE at the top of the cookbook article. Since the feature doesn't exists anymore, I think it's better to leave it aside. I simply mentioned why it's impossible in a short last paragraph at the end of the CB entry. I kept both commit unsquashed because they seemed to address different enough concerns. But I will squash them upon request if you think it's necessary. Commits ------- a6bc497 [Cookbook] Fix doc on Generic Form Type Extensions
I spent almost 15 minutes trying to find how to create a generic Form Type Extension.
I found the doc in http://symfony.com/doc/current/reference/dic_tags.html#form-type-extension and http://stackoverflow.com/questions/24307849/how-to-overwrite-all-symfony2-form-types-and-add-some-property-in-version-2-2 (in which a comment specifies the answer for Symfony 2.3+)
The cookbook article mentions it's possible, but not how to do it.
This PR aims to add the information directly in the cookbook article in order to make it easier to find.