You are here

function linkicon_field_process in Link Icon 7

Overrides link_field_process() to use a select box.

1 string reference to 'linkicon_field_process'
linkicon_element_info_alter in ./linkicon.module
Implements hook_element_info_alter().

File

./linkicon.module, line 219
A link field formatter to create icon classes based on predefined titles.

Code

function linkicon_field_process($element, $form_state, $complete_form) {
  $instance = field_widget_instance($element, $form_state);
  $settings = $instance['settings'];
  if (isset($settings['title_predefined']) && $settings['title_predefined'] && $settings['title'] == 'predefined') {
    $element['title']['#type'] = 'select';
    $element['title']['#options'] = linkicon_extract_allowed_values($settings['title_predefined']);
    $element['title']['#empty_option'] = t('- Select -');
    $element['title']['#default_value'] = isset($element['#value']['title']) ? $element['#value']['title'] : '';

    // Remove irrelevant description.
    unset($element['title']['#description']);
    $element['#element_validate'] = array(
      '_linkicon_element_validate_link_title',
    );
  }
  return $element;
}