You are here

function yamaps_field_settings_form in Yandex.Maps 7

Implements hook_field_settings_form().

File

./yamaps.module, line 276
Yandex Maps module main file.

Code

function yamaps_field_settings_form($field, $instance, $has_data) {
  $settings = $field['settings'];
  $form['display_options'] = [
    '#type' => 'fieldset',
    '#title' => t('Display options'),
    '#tree' => TRUE,
  ];
  $form['display_options']['display_type'] = [
    '#type' => 'radios',
    '#title' => t('Map display style in admin UI for field'),
    '#options' => [
      'map' => t('Map'),
      'map_button' => t('Map opened by button click'),
      'map_without_fields' => t('Map without additional (search, coordinates, etc) fields.'),
    ],
    '#default_value' => $settings['display_options']['display_type'],
    '#required' => FALSE,
    '#description' => t('Configure how to display "Yandex Map" field while creating new / updating material. Applies to admin UI only.'),
  ];
  $form['display_options']['open_button_text'] = [
    '#type' => 'textfield',
    '#title' => t('"Open" button text'),
    '#default_value' => isset($settings['display_options']['open_button_text']) ? $settings['display_options']['open_button_text'] : t(YAMAPS_DEFAULT_OPEN_MAP_TEXT),
    '#required' => FALSE,
    '#description' => t('Specify text to display on button that opens map in case of "Map opened by button click" option. Applies to admin UI only.'),
    '#states' => [
      'visible' => [
        ':input[name="field[settings][display_options][display_type]"]' => [
          'value' => 'map_button',
        ],
      ],
    ],
  ];
  $form['display_options']['close_button_text'] = [
    '#type' => 'textfield',
    '#title' => t('"Close" button text'),
    '#default_value' => isset($settings['display_options']['close_button_text']) ? $settings['display_options']['close_button_text'] : t(YAMAPS_DEFAULT_CLOSE_MAP_TEXT),
    '#required' => FALSE,
    '#description' => t('Specify text to display on button that closes map in case of "Map opened by button click" option. Applies to admin UI only.'),
    '#states' => [
      'visible' => [
        ':input[name="field[settings][display_options][display_type]"]' => [
          'value' => 'map_button',
        ],
      ],
    ],
  ];
  $form['display_options']['width'] = [
    '#title' => t('Map width in admin UI'),
    '#field_suffix' => ' ' . t('in pixels (px) or percentage (%).'),
    '#type' => 'textfield',
    '#default_value' => isset($settings['display_options']['width']) ? $settings['display_options']['width'] : YAMAPS_DEFAULT_ADMIN_UI_MAP_WIDTH,
    '#size' => 5,
    '#element_validate' => [
      'yamaps_field_validate_pixels_percentage',
    ],
    '#required' => TRUE,
    '#description' => t('Set width for the map in field widget of "entity edit" form.'),
  ];
  $form['display_options']['height'] = [
    '#title' => t('Map height in admin UI'),
    '#field_suffix' => ' ' . t('in pixels (px) or percentage (%).'),
    '#type' => 'textfield',
    '#default_value' => isset($settings['display_options']['height']) ? $settings['display_options']['height'] : YAMAPS_DEFAULT_ADMIN_UI_MAP_HEIGHT,
    '#size' => 5,
    '#element_validate' => [
      'yamaps_field_validate_pixels_percentage',
    ],
    '#required' => TRUE,
    '#description' => t('Set height for the map in field widget of "entity edit" form.'),
  ];
  $form['display_options']['controls'] = [
    '#title' => t('Display map controls'),
    '#type' => 'checkbox',
    '#default_value' => isset($settings['display_options']['controls']) ? $settings['display_options']['controls'] : FALSE,
  ];
  $form['display_options']['traffic'] = [
    '#title' => t('Display traffic'),
    '#type' => 'checkbox',
    '#default_value' => isset($settings['display_options']['traffic']) ? $settings['display_options']['traffic'] : FALSE,
  ];
  $form['display_options']['enable_placemarks'] = [
    '#title' => t('Enable placemarks'),
    '#type' => 'checkbox',
    '#default_value' => isset($settings['display_options']['enable_placemarks']) ? $settings['display_options']['enable_placemarks'] : FALSE,
  ];
  $form['display_options']['enable_routes'] = [
    '#title' => t('Enable routes'),
    '#type' => 'checkbox',
    '#default_value' => isset($settings['display_options']['enable_routes']) ? $settings['display_options']['enable_routes'] : FALSE,
  ];
  $form['display_options']['enable_lines'] = [
    '#title' => t('Enable lines'),
    '#type' => 'checkbox',
    '#default_value' => isset($settings['display_options']['enable_lines']) ? $settings['display_options']['enable_lines'] : FALSE,
  ];
  $form['display_options']['enable_polygons'] = [
    '#title' => t('Enable polygons'),
    '#type' => 'checkbox',
    '#default_value' => isset($settings['display_options']['enable_polygons']) ? $settings['display_options']['enable_polygons'] : FALSE,
  ];
  $form['display_options']['clusterer'] = [
    '#title' => t('Use clusterer'),
    '#type' => 'checkbox',
    '#default_value' => isset($settings['display_options']['clusterer']) ? $settings['display_options']['clusterer'] : FALSE,
  ];
  $form['display_options']['auto_zoom'] = [
    '#title' => t('User auto_zoom'),
    '#type' => 'checkbox',
    '#default_value' => isset($settings['display_options']['auto_zoom']) ? $settings['display_options']['auto_zoom'] : FALSE,
  ];
  return $form;
}