You are here

function openlayers_layer_type_kml::options_form_validate in Openlayers 7.2

Validate the options_form().

Parameters

array $default:

Overrides openlayers_layer_type::options_form_validate

File

plugins/layer_types/openlayers_layer_type_kml.inc, line 128
KML Layer Type

Class

openlayers_layer_type_kml
OpenLayers KML Layer Type class

Code

function options_form_validate($form, &$form_state) {
  $method = $form_state['data']['method'];
  if (empty($form_state['data'][$method])) {
    form_set_error($form_state['data']['layer_type'] . '][' . $method, 'The field cannot be empty');
  }
  if ($method == 'file') {
    if ($file = file_load($form_state['data']['file'])) {

      // TODO Why nothing here?
    }
    else {
      form_set_error($form_state['data']['layer_type'] . '][' . $method, 'Cannot access the file.');
    }
  }
  $form_state['data']['formatOptions']['extractStyles'] = $form_state['data']['formatOptions']['extractStyles'] != 0 ? TRUE : FALSE;
  $form_state['data']['formatOptions']['extractAttributes'] = $form_state['data']['formatOptions']['extractAttributes'] != 0 ? TRUE : FALSE;
  $form_state['data']['formatOptions']['extractTracks'] = $form_state['data']['formatOptions']['extractTracks'] != 0 ? TRUE : FALSE;
  $form_state['data']['attribution'] = isset($form_state['data']['attribution']) ? filter_xss($form_state['data']['attribution']) : '';
}