You are here

function link_field_settings_form_validate in Link 7

Form validate.

#element_validate handler for link_field_instance_settings_form().

1 string reference to 'link_field_settings_form_validate'
link_field_instance_settings_form in ./link.module
Implements hook_field_instance_settings_form().

File

./link.module, line 284
Defines simple link field types.

Code

function link_field_settings_form_validate($element, &$form_state, $complete_form) {
  if ($form_state['values']['instance']['settings']['title'] === 'value' && empty($form_state['values']['instance']['settings']['title_value'])) {
    form_set_error('instance][settings][title_value', t('A default title must be provided if the title is a static value.'));
  }
  if ($form_state['values']['instance']['settings']['title'] === 'select' && empty($form_state['values']['instance']['settings']['title_allowed_values'])) {
    form_set_error('instance][settings][title_allowed_values', t('You must enter one or more allowed values for link Title, the title is a selected value.'));
  }
  if (!empty($form_state['values']['instance']['settings']['display']['url_cutoff']) && !is_numeric($form_state['values']['instance']['settings']['display']['url_cutoff'])) {
    form_set_error('display', t('URL Display Cutoff value must be numeric.'));
  }
  if (empty($form_state['values']['instance']['settings']['title_maxlength'])) {
    form_set_value($element['title_maxlength'], '128', $form_state);
  }
  elseif (!is_numeric($form_state['values']['instance']['settings']['title_maxlength'])) {
    form_set_error('title_maxlength', t('The max length of the link title must be numeric.'));
  }
  elseif ($form_state['values']['instance']['settings']['title_maxlength'] > 255) {
    form_set_error('title_maxlength', t('The max length of the link title cannot be greater than 255 characters.'));
  }
}