You are here

public function views_plugin_display_services::options_validate in Services Views 7

Validate the options form.

Overrides views_plugin_display::options_validate

File

includes/views/views_plugin_display_services.inc, line 158
Contains the page display plugin.

Class

views_plugin_display_services
The plugin that handles a Services callback.

Code

public function options_validate(&$form, &$form_state) {

  // It is very important to call the parent function here.
  parent::options_validate($form, $form_state);
  if ($form_state['section'] == 'path') {
    if (preg_match('/[^a-zA-Z0-9-_]+/', $form_state['values']['path'])) {
      form_error($form['path'], t('Use only alphanumeric characters, "-" and "_" for resource name'));
    }

    // Get current path and see if it was changed.
    $current_path = $this
      ->get_option('path');
    if ($current_path != $form_state['values']['path']) {

      // We build resources from database to bypass cache.
      module_load_include('inc', 'services', 'includes/services.resource_build');
      $resources = _services_build_resources();
      if (array_key_exists($form_state['values']['path'], $resources)) {
        form_error($form['path'], t('Resource with this path already exists.'));
      }
    }
  }
}