You are here

function analytics_service_edit_form in Analytics 7

1 string reference to 'analytics_service_edit_form'
analytics_service_export_ui.inc in lib/export_ui/analytics_service_export_ui.inc

File

lib/export_ui/analytics_service_export_ui.inc, line 33

Code

function analytics_service_edit_form(&$form, &$form_state) {
  $service =& $form_state['item'];
  $form['description'] = array(
    '#type' => 'textarea',
    '#title' => t('Description'),
    '#default_value' => $service->description,
    '#rows' => 2,
    '#access' => FALSE,
  );
  if (!$service->service) {
    $options = analytics_service_add_service_options();
    natsort($options);
    $form['service'] = array(
      '#type' => 'select',
      '#title' => t('Service'),
      '#options' => $options,
      '#required' => TRUE,
      '#ajax' => array(
        'callback' => 'analytics_service_edit_form_options_ajax',
        'wrapper' => 'analytics-service-options',
        'method' => 'replace',
        'effect' => 'fade',
      ),
    );
  }
  else {
    $info = analytics_get_service_info($service->service);
    $form['service'] = array(
      '#type' => 'item',
      '#title' => t('Service'),
      '#markup' => $info ? check_plain($info['label']) : check_plain($service->service),
    );
  }
  $new_service = drupal_array_get_nested_value($form_state, array(
    'values',
    'service',
  ));
  if ($new_service && $new_service != $service->service) {
    $service->service = $new_service;
    $service->options = array();
    form_clear_error();
  }
  $form['options'] = array(
    '#type' => 'container',
    '#tree' => TRUE,
    '#prefix' => '<div id="analytics-service-options">',
    '#suffix' => '</div>',
  );
  if ($service->service && ($instance = analytics_get_service_instance($service))) {
    $form['options'] += $instance
      ->buildConfigurationForm($form, $form_state);
  }
}