1 link.module link_field_widget_form(&$form, &$form_state, $field, $instance, $langcode, $items, $delta, $element)

Implements hook_field_widget_form().

File

core/modules/link/link.module, line 367
Defines simple link field types.

Code

function link_field_widget_form(&$form, &$form_state, $field, $instance, $langcode, $items, $delta, $element) {
  $element += array(
    '#type' => $instance['widget']['type'],
    '#default_value' => isset($items[$delta]) ? $items[$delta] : '',
  );
  if ($instance['widget']['type'] == 'link_field') {
    $settings = $instance['settings'];
    if (empty($element['#link_field_options'])) {
      $element['#link_field_options'] = array();
    }
    $element['#link_field_options'] += array(
      'validate_url' => $settings['validate_url'],
      'url_mode' => $settings['url'] ? 'optional' : 'required',
      'link_type' => $settings['type'],
      'title_mode' => $settings['title'],
      'title_label_use_field_label' => $settings['title_label_use_field_label'],
      'title_maxlength' => $settings['title_maxlength'],
      'target' => $settings['attributes']['target'],
      'configurable_title' => $settings['attributes']['configurable_title'],
      'configurable_class' => $settings['attributes']['configurable_class'],
    );
  }
  return $element;
}