You are here

function leaflet_field_formatter_settings_form in Leaflet 7

Implements hook_field_formatter_settings_form().

File

./leaflet.formatters.inc, line 74
Leaflet field formatter functions.

Code

function leaflet_field_formatter_settings_form($field, $instance, $view_mode, $form, &$form_state) {
  $display = $instance['display'][$view_mode];
  $settings = $display['settings'];
  $entity_type = $instance['entity_type'];
  $element = array();
  if ($display['type'] == 'geofield_leaflet') {
    $options = array(
      '' => t('-- Select --'),
    );
    foreach (leaflet_map_get_info() as $key => $map) {
      $options[$key] = $map['label'];
    }
    $element['leaflet_map'] = array(
      '#title' => t('Leaflet Map'),
      '#type' => 'select',
      '#options' => $options,
      '#default_value' => $settings['leaflet_map'],
      '#required' => TRUE,
    );
    $element['height'] = array(
      '#title' => t('Map Height'),
      '#type' => 'textfield',
      '#default_value' => $settings['height'],
      '#field_suffix' => t('px'),
      '#element_validate' => array(
        'element_validate_integer_positive',
      ),
    );
    foreach ($form['#fields'] as $fieldname) {
      $field_options[$fieldname] = $fieldname;
    }
    $fieldpath = 'fields[' . $field['field_name'] . '][settings_edit_form][settings]';
    $element['popup'] = leaflet_form_elements('popup', $settings, array(
      'path' => $fieldpath,
    ));
    $element['zoom'] = leaflet_form_elements('zoom', $settings);
    $element['icon'] = leaflet_form_elements('icon', $settings, array(
      'path' => $fieldpath,
      'fields' => $field_options,
    ));
    $element['vector_display'] = leaflet_form_elements('vector_display', $settings, array(
      'path' => $fieldpath,
    ));

    // Show the list of available tokens.
    $element['tokens'] = leaflet_form_elements('tokens', $settings, array(
      'weight' => 999,
      'entity_type' => $entity_type,
    ));
  }
  return $element;
}