Check minimal field requirement validation

Created on 28 July 2019, almost 6 years ago
Updated 6 May 2025, 8 days ago

Just found this old Drupal 7 code.


/**
 * Validates if an unused component is selected as a minimal component.
 */
function _name_field_minimal_component_requirements($element, &$form_state) {
  $required_field_set = array_flip(['given', 'family']);
  $value = array_intersect_key($required_field_set, array_filter((array) $element['#value']));
  if (empty($value)) {
    $required_fields = array_intersect_key(_name_translations(), $required_field_set);
    form_set_error(implode('][', $element['#parents']) . '][given]',
        t('@label must have one of the following components: %components',
        ['@label' => $element['#title'], '%components' => implode(', ', $required_fields)]));
  }
}
πŸ“Œ Task
Status

Postponed: needs info

Version

1.0

Component

Code

Created by

πŸ‡¦πŸ‡ΊAustralia alan d.

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024