You are here

function pardot_webform_components_form in Pardot Integration 7

Same name and namespace in other branches
  1. 6 pardot.admin.inc \pardot_webform_components_form()
  2. 7.2 pardot_webform/pardot_webform.admin.inc \pardot_webform_components_form()

Form constructor for the pardot webform management form.

Parameters

node $webform_node: The webform node pardot information is attached to.

See also

pardot_webform_components_form_validate()

pardot_webform_components_form_submit()

pardot_webform_components_form_delete_submit()

1 string reference to 'pardot_webform_components_form'
pardot_menu in ./pardot.module
Implements hook_menu().

File

./pardot.admin.inc, line 142
Admin forms.

Code

function pardot_webform_components_form($form, $form_state, $webform_node) {
  $form = array();
  $form['#tree'] = TRUE;
  $form['#node'] = $webform_node;
  $nid = $webform_node->nid;
  $record = pardot_webform_load($nid);
  $form['#record'] = $record;
  if (!isset($record->is_active)) {
    $record = new stdClass();
    $record->is_active = "";
    $record->url = "";
  }
  $form['details'] = array(
    '#type' => 'fieldset',
    '#title' => t('General'),
  );
  $form['details']['is_active'] = array(
    '#title' => 'Is active',
    '#type' => 'checkbox',
    '#default_value' => $record->is_active,
  );
  $form['details']['url'] = array(
    '#title' => 'Post url',
    '#type' => 'textfield',
    '#default_value' => $record->url,
    '#description' => t('Visit your "Form Handlers" page in Pardot. Click on a form link and then copy the "Endpoint URL" value here.<br /><br />!example', array(
      '!example' => theme('image', array(
        'path' => drupal_get_path('module', 'pardot') . '/form-handler-url.jpg',
      )),
    )),
  );
  $form['components'] = array(
    '#tree' => TRUE,
  );
  foreach ($webform_node->webform['components'] as $k => $component) {
    $form['components'][$k] = array(
      '#component' => $component,
      'key' => array(
        '#title' => 'Field name',
        '#type' => 'textfield',
        '#size' => 25,
        '#default_value' => isset($record->data[$component['form_key']]['key']) ? $record->data[$component['form_key']]['key'] : '',
      ),
    );
  }
  $form['actions']['save'] = array(
    '#type' => 'submit',
    '#value' => t('Save'),
  );
  $form['actions']['delete'] = array(
    '#type' => 'submit',
    '#value' => t('Reset'),
    '#submit' => array(
      'pardot_webform_components_form_delete_submit',
    ),
  );
  return $form;
}