You are here

function eloqua_webform_form_webform_component_edit_form_alter in Eloqua 7.2

Same name and namespace in other branches
  1. 7 eloqua_webform/eloqua_webform.module \eloqua_webform_form_webform_component_edit_form_alter()

Implements hook_form_FORM_ID_alter().

This function is reponsible for adding the form-id mapping values to the Component add/edit page. Note: This isn't used for the fieldset type.

File

eloqua_webform/eloqua_webform.module, line 50

Code

function eloqua_webform_form_webform_component_edit_form_alter(&$form, $form_state) {
  if (!array_key_exists('build_info', $form_state) || !array_key_exists('args', $form_state['build_info']) || !array_key_exists(1, $form_state['build_info']['args'])) {
    return;
  }
  $component = $form_state['build_info']['args'][1];

  // Create the fieldset.
  $form['eloqua'] = array(
    '#type' => 'fieldset',
    '#title' => t('Eloqua'),
    '#tree' => TRUE,
  );

  // Check the field type. Some do not make sense as having a value to post to
  // Eloqua.
  $component_type = $component['type'];
  if (in_array($component_type, array(
    'fieldset',
    'pagebreak',
  ))) {

    // todo: Get this working
    $form['eloqua']['msg'] = array(
      '#markup' => t('This component type is not compatible with the Eloqua Module.'),
    );
    return;
  }
  else {
    $form['eloqua']['key'] = array(
      '#type' => 'textfield',
      '#default_value' => isset($component['extra']['eloqua']['key']) ? $component['extra']['eloqua']['key'] : '',
      '#title' => t('Eloqua Field Name'),
      '#description' => t('The eloqua field name if it contains symbols or characters not compatible with the defaults above. Leave empty to use the default above. Can not contain spaces.'),
      '#weight' => 0,
    );
    $form['eloqua']['query_name'] = array(
      '#type' => 'textfield',
      '#default_value' => isset($component['extra']['eloqua']['query_name']) ? $component['extra']['eloqua']['query_name'] : '',
      '#description' => t('If this value can be populated by a query parameter, the key that is to be used. Can only contain the characters a-z A-Z 0-9 and _.'),
      '#title' => t('Request Parameter Key'),
    );
    $form['#validate'][] = 'eloqua_webform_component_edit_form_validate';
  }
}