You are here

function openlayers_views_form_alter in Openlayers 6.2

Implementation of hook_form_alter()

File

modules/openlayers_views/openlayers_views.module, line 136
This file holds the main Drupal hook functions and private functions for the openlayers_views module.

Code

function openlayers_views_form_alter(&$form, $form_state, $form_id) {
  switch ($form_id) {
    case 'openlayers_ui_object_export':

      // prevent exporting in the openlayers interface
      if (isset($form['#parameters'][3]->data['layer_type']) && $form['#parameters'][3]->data['layer_type'] == 'openlayers_views_vector') {
        if (module_exists('views_ui')) {
          $form['export'] = array(
            '#value' => t('This layer is provided by a view, so it must be exported via the
              Views interface as a view. <a href="@url">Export this view
              using the views module.</a>', array(
              '@url' => url('admin/build/views/export/' . $form['#parameters'][3]->data['views']['view']),
            )),
          );
          unset($form['done']);
        }
        else {
          $form['export'] = array(
            '#value' => t('This layer is provided by a view, so it must be exported via the
              Views interface as a view. Enable the Views UI
              module to export it.'),
          );
          unset($form['done']);
        }
      }
      break;
    case 'openlayers_ui_layers_form':

      // prevent cloning in the openlayers interface
      if (isset($form['#parameters'][2]->data['layer_type']) && $form['#parameters'][2]->data['layer_type'] == 'openlayers_views_vector') {
        $form = array(
          'message' => array(
            '#value' => t('This layer is provided by a view, so it can be cloned by cloning
              the view in the <a href="@url">Views interface.</a>', array(
              '@url' => url('admin/build/views/'),
            )),
          ),
        );
      }
      break;
  }
}