You are here

function _name_field_settings_form_validate in Name Field 7

Implements the validation callback for the name_field_settings_form() form.

This is an #element_validate callback.

@todo Ensure that the #parent path is correct in all instances. This avoids the need to pull out individual values from the $elements[xx][#value].

1 call to _name_field_settings_form_validate()
name_field_settings_form_validate in ./name.module
Implements hook_field_settings_form_validate().
1 string reference to '_name_field_settings_form_validate'
_name_field_settings_form in includes/name.content.inc
Implements hook_field_settings_form().

File

includes/name.content.inc, line 170
Provides additional Field functionality for the name module.

Code

function _name_field_settings_form_validate($elements, &$form_state, $form) {
  $values = $form_state['values']['field']['settings'];

  // Validates options against the title / generational sizes.
  _name_options_validate($values['title_options'], $values['max_length']['title'], t('Title options'), 'field][settings][title_options');
  _name_options_validate($values['generational_options'], $values['max_length']['generational'], t('Generational options'), 'field][settings][generational_options');

  // Validates that a minimum component is not selected when that component is
  // not selected.
  _name_field_components_validate($values['components'], $values['minimum_components'], 'field][settings][minimum_components');
  if (!empty($form_state['values']['instance'])) {
    $instance_settings = $form_state['values']['instance']['settings'];
    $instance_components = array_filter($instance_settings['components']);
    $instance_minimum_components = array_filter($instance_settings['minimum_components']);
    if ($instance_components && $instance_minimum_components) {
      _name_field_components_validate($instance_components, $instance_minimum_components, 'instance[settings][minimum_components');
    }
    elseif ($instance_minimum_components) {
      _name_field_components_validate($values['components'], $instance_minimum_components, 'instance[settings][minimum_components');
    }
    elseif ($instance_components) {
      _name_field_components_validate($instance_components, $values['minimum_components'], 'instance[settings][components');
    }
  }
}