ICT:Drupal Standard: Field naming Convention
Appearance
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(wherexxis the unique prefix). - Example:
field_sa_namefor Sanatoria,field_pa_surnamefor 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_validateautomatically 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 |