You are here

function _webform_client_form_add_component in Webform 5.2

Same name and namespace in other branches
  1. 5 webform.module \_webform_client_form_add_component()
  2. 6.3 webform.module \_webform_client_form_add_component()
  3. 6.2 webform.module \_webform_client_form_add_component()
  4. 7.4 webform.module \_webform_client_form_add_component()
  5. 7.3 webform.module \_webform_client_form_add_component()
1 call to _webform_client_form_add_component()
webform_client_form in ./webform.module
Client form generation function. If this is displaying an existing submission, pass in the $submission variable with the contents of the submission to be displayed.

File

./webform.module, line 1417

Code

function _webform_client_form_add_component($cid, $component, &$parent_fieldset, &$form, $submission, $page_num, $enabled = FALSE) {

  // Load with submission information if necessary.
  if (!$enabled) {

    // This component is display only.
    $display_function = '_webform_submission_display_' . $component['type'];
    if (function_exists($display_function)) {
      $parent_fieldset[$component['form_key']] = $display_function(empty($submission->data[$cid]) ? NULL : $submission->data[$cid], $component, $enabled);
    }
  }
  elseif ($component['page_num'] == $page_num) {

    // Add this user-defined field to the form (with all the values that are always available).
    if (isset($submission->data)) {
      $display_function = '_webform_submission_display_' . $component['type'];
      if (function_exists($display_function)) {
        $parent_fieldset[$component['form_key']] = $display_function($submission->data[$cid], $component, $enabled);
      }
    }
    else {
      $render_function = '_webform_render_' . $component['type'];
      if (function_exists($render_function)) {
        $parent_fieldset[$component['form_key']] = $render_function($component);

        // Call the component render function.
      }
      else {
        drupal_set_message(t('The webform component @type is not able to be displayed', array(
          '@type' => $component['type'],
        )));
      }
    }
  }
  if (isset($component['children']) && is_array($component['children'])) {
    $microweight = 0.001;
    foreach ($component['children'] as $scid => $subcomponent) {
      _webform_client_form_add_component($scid, $subcomponent, $parent_fieldset[$component['form_key']], $form, $submission, $page_num, $enabled);
      $parent_fieldset[$component['form_key']][$subcomponent['form_key']]['#weight'] += $microweight;
      $microweight += 0.001;
    }
  }
}