You are here

function webform_ajax_form_webform_configure_form_alter in Webform Ajax 7

Same name and namespace in other branches
  1. 7.2 webform_ajax.module \webform_ajax_form_webform_configure_form_alter()

Implements hook_form_FORM_ID_alter().

With FORM_ID = webform_configure_form. Add AJAX option to Webform configure form.

File

./webform_ajax.module, line 39
Webform AJAX module file.

Code

function webform_ajax_form_webform_configure_form_alter(&$form, &$form_state) {
  $node = $form_state['build_info']['args'][0];
  $form['webform_ajax_fieldset'] = array(
    '#type' => 'fieldset',
    '#title' => t('AJAX'),
    '#collapsible' => TRUE,
    '#collapsed' => $node->webform['webform_ajax'] == WEBFORM_AJAX_NO_AJAX,
  );
  $form['webform_ajax_fieldset']['webform_ajax'] = array(
    '#type' => 'checkbox',
    '#title' => t('AJAX mode'),
    '#description' => t('When set, all page changes (from pagebreak component), and webform submission will be achieved in AJAX.'),
    '#default_value' => $node->webform['webform_ajax'] != WEBFORM_AJAX_NO_AJAX,
  );
  $form['webform_ajax_fieldset']['webform_ajax_confirmation'] = array(
    '#type' => 'checkbox',
    '#title' => t('Show confirmation screen'),
    '#description' => t('Choose whether to retrieve in AJAX, after webform submit, the confirmation screen, or the webform itself. Available only when redirection is set to "No redirect".'),
    '#default_value' => $node->webform['webform_ajax'] == WEBFORM_AJAX_NO_CONFIRM ? FALSE : TRUE,
    '#states' => array(
      'visible' => array(
        ':input[name="redirect"]' => array(
          'value' => 'none',
        ),
        '#edit-webform-ajax' => array(
          'checked' => TRUE,
        ),
      ),
    ),
  );
  array_unshift($form['#submit'], 'webform_ajax_webform_configure_form_submit');
}