Skip to content

Added a new best practices for custom form field types #5093

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

Merged
merged 2 commits into from
Mar 24, 2015

Conversation

javiereguiluz
Copy link
Member

Q A
Doc fix? no
New docs? yes
Applies to all
Fixed tickets #5077


Add the ``app.`` prefix to your custom form field types to avoid collisions.

Custom form field types extend from the ``AbstractType`` class, which defines the
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"extend the" or "inherit from" I guess.


.. best-practice::

Add the ``app.`` prefix to your custom form field types to avoid collisions.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dots are forbidden in type names, so your suggestion is really bad. Recommend app_ instead.

for reference, type names are validated as /^[a-z0-9_]*$/i

@wouterj
Copy link
Member

wouterj commented Mar 19, 2015

I see a little problem here: We already have quite a few best practices just recommending an app prefix (some with a dot, some with an underscore, some with a namespace, etc.). Going like that, don't we end up writing a best practice about such a prefix for all customizable things in Symfony? (e.g. use the app: prefix for commands, ...).

I think it is better if we just replace all these best practice with one best practice: Always prefix with app. We add this to the AppBundle article. If we think the suffix of this might be confusing (dot, underscore, dash, colon, ...) we can add a list of examples.

What's your opinion about this?

@weaverryan
Copy link
Member

@wouterj I hear what you're saying, it might not be a bad idea. But what are the places we prefix? I can think of:

  1. form type names
  2. service ids

I'm probably missing a few, but I'm not sure.

@weaverryan
Copy link
Member

I've merged this in - there was no disagreement here or on the issue, and I can't think of why there would be any. But @wouterj, I don't want to lose your point - so please reply and we can definitely reformat how we're communicating the best practices. Javier, I updated #5077's description to have 2 checkboxes - the second one is to update the documentation to add the app_ prefix. Thanks!

@weaverryan weaverryan merged commit 0696daf into symfony:2.3 Mar 24, 2015
weaverryan added a commit that referenced this pull request Mar 24, 2015
…(javiereguiluz)

This PR was merged into the 2.3 branch.

Discussion
----------

Added a new best practices for custom form field types

| Q             | A
| ------------- | ---
| Doc fix?      | no
| New docs?     | yes
| Applies to    | all
| Fixed tickets | #5077

Commits
-------

0696daf Fixed errors, typos and grammar issues. (I managed to fail at everything!)
8eb1240 Added a new best practices for custom form field types
@javiereguiluz javiereguiluz deleted the fix_5077 branch January 3, 2018 16:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants