0

I'm implementing a giant list of fields, instances, bundles, et cetera in a custom site specific module.

In progress, I see that the core Tags vocabulary has a field_ machine name prefix, and none of my custom vocabularies have this prefix. I've known that creating fields through the Drupal GUI also prefixes fields with field_.

In my previous experience working with prefixed fields, this has always seemed too verbose.

Is prefixing Field API fields with _field a best practice for a reason I haven't come across yet?

2 Answers 2

3

I prefix my custom fields always with the name of my module, which, I think, is a good practice, so that I know which module provides this field. And also I think this is the same reason Drupal Field UI adds the field_ prefix since the fields are created by the Field module in this case.

0

In our team we make the following naming.

field_NAME_OF_PROJECT_NAME_OF_MODULE_FIELD_NAME

Example: Project: Rockstar Module: Counter Field Name: id

Final:field_rs_counter_id Keep in mind those are saved in the database as field_data_field_rs_counter_id, and I experienced character limit.

Regards

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.