You are here

function template_preprocess_webform_form in Webform 7.4

Same name and namespace in other branches
  1. 6.3 webform.module \template_preprocess_webform_form()
  2. 6.2 webform.module \template_preprocess_webform_form()
  3. 7.3 webform.module \template_preprocess_webform_form()

Prepare for theming of the webform form.

File

./webform.module, line 3573
This module provides a simple way to create forms and questionnaires.

Code

function template_preprocess_webform_form(&$vars) {
  if (isset($vars['form']['details']['nid']['#value'])) {
    $vars['nid'] = $vars['form']['details']['nid']['#value'];
  }
  elseif (isset($vars['form']['submission']['#value'])) {
    $vars['nid'] = $vars['form']['submission']['#value']->nid;
  }
  if (!empty($vars['form']['#node']->webform['conditionals']) && empty($vars['form']['preview'])) {
    module_load_include('inc', 'webform', 'includes/webform.conditionals');
    $submission_data = isset($vars['form']['#conditional_values']) ? $vars['form']['#conditional_values'] : array();
    $settings = webform_conditional_prepare_javascript($vars['form']['#node'], $submission_data, $vars['form']['details']['page_num']['#value']);
    drupal_add_js(array(
      'webform' => array(
        'conditionals' => array(
          'webform-client-form-' . $vars['nid'] => $settings,
        ),
      ),
    ), 'setting');
  }
}