You are here

function eloqua_form_webform_configure_form_alter in Eloqua 6

Implementation of hook_form_FORM_ID_alter().

File

./eloqua.module, line 173

Code

function eloqua_form_webform_configure_form_alter(&$form, $form_state) {
  $form['#submit'][] = 'eloqua_form_webform_configure_form_submit';
  $form['#validate'][] = 'eloqua_form_webform_configure_form_validate';

  // Load the form options from the database if available
  $settings = new stdClass();
  if (!empty($form['nid']['#value'])) {
    $settings = eloqua_webform_load($form['nid']['#value']);
  }

  // Apply default settings
  if (!isset($settings->{ELOQUA_WEBFORM_FIELD_ACTIVE})) {
    $settings->{ELOQUA_WEBFORM_FIELD_ACTIVE} = 0;
  }
  if (!isset($settings->{ELOQUA_WEBFORM_FIELD_FORM_NAME})) {
    $settings->{ELOQUA_WEBFORM_FIELD_FORM_NAME} = '';
  }
  if (!isset($settings->{ELOQUA_WEBFORM_FIELD_DATA})) {
    $settings->{ELOQUA_WEBFORM_FIELD_DATA} = new stdClass();
  }
  if (!isset($settings->{ELOQUA_WEBFORM_FIELD_DATA}->process_every_page)) {
    $settings->{ELOQUA_WEBFORM_FIELD_DATA}->process_every_page = 0;
  }
  $form['eloqua'] = array(
    '#type' => 'fieldset',
    '#description' => t('Eloqua Integration Options'),
    '#title' => t('Eloqua'),
    '#collapsible' => TRUE,
    '#collapsed' => FALSE,
    'elq_enabled' => array(
      '#type' => 'checkbox',
      '#default_value' => $settings->{ELOQUA_WEBFORM_FIELD_ACTIVE},
      '#description' => t('Whether this form is eloqua enabled'),
      '#title' => t('Enabled'),
    ),
    'elq_form_name' => array(
      '#type' => 'textfield',
      '#default_value' => $settings->{ELOQUA_WEBFORM_FIELD_FORM_NAME},
      '#description' => t('The form name as it is defined in Eloqua'),
      '#title' => t('Eloqua Form Name'),
    ),
    'elq_process_every_page' => array(
      '#type' => 'checkbox',
      '#default_value' => $settings->{ELOQUA_WEBFORM_FIELD_DATA}->process_every_page,
      '#description' => t('Process every page submit on a multi-page form, instead of one combined submit upon completion.'),
      '#title' => t('Process subpages seperately'),
    ),
  );
}