Closed (fixed)
Project:
Examples for Developers
Component:
Node Example
Priority:
Normal
Category:
Bug report
Assigned:
Reporter:
Created:
18 Mar 2010 at 16:29 UTC
Updated:
12 Jun 2010 at 01:50 UTC
Jump to comment: Most recent file
In order to avoid collisions, fields should be named modulename_fieldname. (I'm sure this is documented somewhere, but I couldn't find it - it follows general guidelines and good sense though!)
Attached patch attaches the node_example_ prefix to the color, quantity and image fields defined in node_example module.
| Comment | File | Size | Author |
|---|---|---|---|
| #11 | node_example_field_prefix.patch | 3.21 KB | tanoshimi |
| #5 | examples_nodeprefix2.patch | 2.13 KB | tanoshimi |
| examples_nodeprefix.patch | 2.19 KB | tanoshimi |
Comments
Comment #1
rfay@tanoshimi, glad to have you participating. Thanks for the patch!
If you want this change, though, please point to a reference in the coding standards (or some other source) that justifies this.
Thanks,
-Randy
Comment #2
tanoshimi commentedI can't find it written in plain black and white, however I can find two things to support this:
1.) From: http://api.drupal.org/api/group/field_structs/7
"field_name (string) The name of the field. Each field name is unique within Field API."
Prefixing each field with the name of the module that created it ensures that this statement remains true when a module defines a new field (and that there isn't, for example, another module that defines a "color", "quantity" or "image" field).
2.) This is the convention followed by all the fields shipped with D7 core - the tags fields defined by taxonomy module is taxonomy_tags, the image field defined by field module is field_image etc.
Comment #3
rfay+1: I'd say that's an adequate argument. You should perhaps file an issue to get that convention added to the coding standards or somewhere, as it is perfectly logical.
It's one of those things that's new to D7, so hasn't yet been properly addressed. I encourage you to chat with yched and bjaspan about how to get this documented and agreed upon.
Comment #5
tanoshimi commentedlet's have another go...
Comment #7
rfay@tanoshimi, it looks like you updated the module but forgot to update the test:
http://qa.drupal.org/pifr/test/40558
Please reroll, and it avoids frustration to run the tests on your local machine.
Thanks!
-Randy
Comment #8
tanoshimi commentedHi Randy -
Thanks - I realised that I forgot to update the test but was waiting for confirmation of #746328: Document coding standards for field naming (D7) before resubmitting (also think that the token test might have been broken when last submitted)
Comment #9
rfayRelated issue: #796988: Multiple types and related hook naming
Comment #10
rfay@tanoshimi, I think this will be fine regardless of the non-status of #746328: Document coding standards for field naming (D7). Go for it.
Comment #11
tanoshimi commentedOk. Third try lucky... fingers crossed!
Comment #13
rfayThe queue_example #fail is (almost) certainly not your fault - I'm retesting HEAD to see: http://qa.drupal.org/pifr/test/26934
Thanks for your work on this! You're almost there!
Comment #14
rfayUpdate: Looks like HEAD is broken: http://qa.drupal.org/pifr/test/26934
I'll take a look at it and then resubmit this one after HEAD is fixed.
Comment #15
rfayAlmost got HEAD working, but still one #fail.
Comment #16
rfay#11: node_example_field_prefix.patch queued for re-testing.
Comment #17
rfayCommitted to HEAD: http://drupal.org/cvs?commit=372806
Thanks! I look forward to more contributions from you to make this project better.