You are here

function _name_field_minimal_component_requirements in Name Field 7

Same name and namespace in other branches
  1. 6 name.module \_name_field_minimal_component_requirements()

Checks that a component is not selected as a minimal component when the component is not selected.

3 string references to '_name_field_minimal_component_requirements'
_name_field_instance_settings_form in includes/name.content.inc
Implements hook_field_instance_settings_form().
_name_field_settings_form in includes/name.content.inc
Implements hook_field_settings_form().
_webform_edit_name in includes/webform.components.inc
Implements Webform callback _webform_edit_COMPONENT().

File

./name.module, line 1054
Defines an API for displaying and inputing names.

Code

function _name_field_minimal_component_requirements($element, &$form_state) {
  $values = array_filter((array) $element['#value']);
  if ($values) {
    $required_field_set = array_flip(array(
      'given',
      'family',
    ));
    $values = array_intersect_key($required_field_set, $values);
    if (empty($values)) {
      $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', array(
        '!label' => $element['#title'],
        '%components' => implode(', ', $required_fields),
      )));
    }
  }
}