Skip to content
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

FormTypeInterface::getName() is deprecated #5588

Closed
xabbuh opened this issue Aug 1, 2015 · 8 comments
Closed

FormTypeInterface::getName() is deprecated #5588

xabbuh opened this issue Aug 1, 2015 · 8 comments
Labels
actionable Clear and specific issues ready for anyone to take them. Form hasPR A Pull Request has already been submitted for this issue.
Milestone

Comments

@xabbuh
Copy link
Member

xabbuh commented Aug 1, 2015

As of Symfony 2.8, implementing the getName() method of the FormTypeInterface() is deprecated. Instead, form types should be referenced by their FQCN (which is quite easy as PHP supports the class constant since 5.5). Additionally, you should now also not use the alias attribute anymore when tagging your services as a form type using the form.type tag.

More detailed information and examples can be found in the code PR (see symfony/symfony#15079) which has just been merged.

@xabbuh xabbuh added Missing Documentation actionable Clear and specific issues ready for anyone to take them. Form labels Aug 1, 2015
@xabbuh xabbuh added this to the 2.8 milestone Aug 1, 2015
@javiereguiluz
Copy link
Member

Given that Symfony 2.8 is designed for PHP 5.3.9 and up, docs should display both the short ::class examples and the long/verbose alternatives for 5.3 and 5.4.

@xabbuh
Copy link
Member Author

xabbuh commented Aug 1, 2015

Indeed, that's a good hint, Javier!

@weaverryan weaverryan added the hasPR A Pull Request has already been submitted for this issue. label Nov 22, 2015
weaverryan added a commit that referenced this issue Nov 27, 2015
…ponent (hiddewie)

This PR was merged into the 2.8 branch.

Discussion
----------

Updated form aliases to FQCNs for forms in book and component

| Q             | A
|------------- | ---
| Doc fix?      | yes
| New docs?     | no
| Applies to    | 2.8+
| Fixed tickets | #5588

For the 3.0 branch, all FQCNs should be updated to use the `::class` constant.

Commits
-------

e103627 Fixed wrong indendation
f8b080d Found more places which use old form types
3237a34 Updated form constant usage
3ab3830 Fixed PHP 5.5+ reference in form component
291a42a Fixed removed XML tag in form book
0820e69 Updated form aliases to FQCNs for forms in book and component
@weaverryan
Copy link
Member

Please see #5909, for the second set of huge changes for this :)

weaverryan added a commit that referenced this issue Nov 30, 2015
This PR was merged into the 2.8 branch.

Discussion
----------

More 2.8 form updates

| Q             | A
|------------- | ---
| Doc fix?      | yes
| New docs?     | no
| Applies to    | 2.8+
| Fixed tickets | #5588

This is addition to what was done in #5834. These changes are HUGE, so if anyone can review this for copy-paste changes or other mistakes, that would be awesome. Also, if you can think of any other things to search for the the code base and are able to find MORE instances, let me know.

Commits
-------

d131449 several other tweaks
feb68dd Completely updating the form type reference section for the text -> TextType changes
832a12a fixing build error
3117df5 Another huge batch of changes for the form type changes in 2.8
@pfleu
Copy link
Contributor

pfleu commented May 3, 2016

Does this mean you can't customize a form's name anymore ? I have custom prototype entry_rows for some collections that I would need to use from different forms, so I need to change the form's name.

@stof
Copy link
Member

stof commented May 3, 2016

@pfleu I think you are confusing the form name and the form type name

@pfleu
Copy link
Contributor

pfleu commented May 4, 2016

@stof Thanks for your answer. I wanted to change what is now called blockPrefix. I had an answer on StackOverflow, it looks like getName() has been replaced with getBlockPrefix().
My problem was I have two forms: formA with field myCollection, and formB, which also has a field myCollection. So in my custom prototype form, if I write a block like _formA_myCollection_entry_row, it won't be recognized when I call my formB, because this time it will be called _formB_myCollection_entry_row. By changing the form's name, I don't have to duplicate my prototype entry_row.

@HeahDude
Copy link
Contributor

HeahDude commented May 4, 2016

@pfleu your question is logical. But the block prefix is not the same as the name, note that the usage of the name has been deprecated in many function call in favor of the FQCN.

You can also change the block prefix used in templates dynamically by using the option block_name.

Hope that helps, cheers!

@pfleu
Copy link
Contributor

pfleu commented May 4, 2016

@HeahDude Thanks for your explanations!

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 hasPR A Pull Request has already been submitted for this issue.
Projects
None yet
Development

No branches or pull requests

6 participants