Jump to content

ICT:Drupal Standard: Field naming Convention

From Costa Sano MediaWiki

ICT Standard: Field Naming Conventions

To ensure the Heritage Tweaks module functions correctly and the database remains organized, all new fields must follow this dual-naming convention.

1. The Prefix Rule (Namespace)

All field machine names must start with a two-character code representing the Content Type.

  • Pattern: field_xx_fieldname (where xx is the unique prefix).
  • Example: field_sa_name for Sanatoria, field_pa_surname for Patients.
  • Benefit: Prevents naming collisions and makes Configuration Management (CM) easier to filter.

2. The Suffix Rule (Functional Hook)

Any text field intended to store a historical date in dd/mm/yyyy format must end with the suffix _day.

  • Pattern: field_xx_customname_day
  • Example: field_sa_foundation_day
  • Logic: The PHP function heritage_tweaks_date_validate automatically scans for this suffix to apply:
    • Automatic UI Placeholders (dd/mm/yyyy).
    • RegEx format validation.
    • Calendar sanity checks (Leap years/invalid months).

Summary Table for Successors

Field Purpose Required Suffix Resulting Behavior
Standard Text (None) Normal Drupal behavior
Historical Date _day Text-entry with DD/MM/YYYY validation