You are here

function mobile_number_field_widget_settings_validate in Mobile Number 7

Field instance settings validate callback.

1 string reference to 'mobile_number_field_widget_settings_validate'
mobile_number_field_widget_settings_form in ./mobile_number.module
Implements hook_field_widget_settings_form().

File

./mobile_number.module, line 464
mobile_number.module

Code

function mobile_number_field_widget_settings_validate($element, &$form_state) {
  $parents = $element['#parents'];
  array_pop($parents);
  $values = drupal_array_get_nested_value($form_state['values'], $parents);
  if (!empty($values['message'])) {
    t($values['message']);
  }
  $default_country = $values['default_country'];
  $allowed_countries = $values['countries'];
  if (!empty($allowed_countries) && empty($allowed_countries[$default_country])) {
    form_error($element, t('Default country is not in one of the allowed countries.'));
  }
}