1 link.module link_element_info()

Implements hook_element_info().

The #default_value should be an array with the following keys:

  '#default_value' => array(
    'url' => 'admin/content',
    'title' => 'List of content',
    'attributes' => array( // These are extra elements (see flags below)
      'title' => 'A link to Content', // Prepopulates the "title" attribute.
      'class' => 'additional-css-class',
      'target' => '_blank',
    ),
  ),

@since 1.30.0 The "#link_field_options" property added.

File

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

Code

function link_element_info() {
  $elements = array();
  // We use "link_field" here to avoid conflicts with theme_link().
  // Many of these properties are related to the Field API Link field settings.
  $elements['link_field'] = array(
    '#input' => TRUE,
    '#process' => array('link_field_process'),
    '#theme' => 'link_field',
    '#theme_wrappers' => array('link_field_wrapper'),
    '#element_validate' => array('link_field_element_validate'),

    // Custom options for link_field. Defaults are provided within
    // link_field_process().
    '#link_field_options' => array(),

    // #delta is typically passed by the widget form, but we provide a default
    // value to help validations when link_field is used as a FAPI element.
    '#delta' => 0,

    // Attach the css by default.
    '#attached' => array(
      'css' => array(
        backdrop_get_path('module', 'link') . '/css/link.css',
      ),
    ),
  );
  return $elements;
}