2

I have a question about best-practice for naming fields; I am creating a craft site for a football club, which include the following:

  • club name (Global)
  • team names
  • player names

These are all plaintext fields. In the interest of being DRY, should I create one 'Name' field for all? Is this problematic - and therefore better to create different fields for each, so I have teamName, playerName, clubName handles etc?

2 Answers 2

2

If the fields can all use the same description and settings (allow multiple lines, text size), you could use the same field (we do).

If there's even the slightest chance the description need to be different (in the future), create different fields (or use the Relabel plugin to create different names and descriptions for the same field).

5

The job of naming something is sometimes the most difficult part of a project! This is pretty subjective, but even though it seems like those three fields would share the same settings and requirements (as mentioned by @Paul Werheul), if it was me I would choose field names like clubName, teamName, and playerName.

This way the field names explicitly state what is expected to be entered or returned in your template.

My very humble two cents!

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.