You are here

function signup_webform_form in Signup 6.2

Signup form pane callback.

Parameters

&$signup_form: The form array for the whole signup. You should not alter this, but it contains useful data depending on circumstances.

&$form_state: Likewise.

$node: The fully loaded node object.

$signup: If this is an existing signup, the fully loaded signup object. If this is a new signup, this is just NULL.

$pane_id: The pane ID being invoked. This allows a module to implement multiple panes with one callback.

$signup_type: Determines what kind of signup to generate a form for. Possible values: 'auth' -- regular authenticated user signup form 'anon' -- anonymous user signup form (includes required email field). 'admin' -- admin form to signup another user (includes user selector).

Return value

A form API array for insertion into the signup form.

1 string reference to 'signup_webform_form'
signup_webform_signup_pane_info in modules/signup_webform/signup_webform.module
Implementation of hook_signup_pane_info().

File

modules/signup_webform/signup_webform.module, line 115
signup_webform.module

Code

function signup_webform_form(&$signup_form, &$form_state, $node, $signup, $pane_id, $signup_type = 'auth') {
  $form = array();

  // Get the real nid from the prefixed pane ID and thence the node.
  $webform_nid = substr($pane_id, 8);
  $webform_node = node_load($webform_nid);
  module_load_include('inc', 'webform', 'webform_components');
  webform_load_components();

  // Load the webform submission for existing signups, so the webform API
  // takes care of putting in existing data.
  if (isset($signup) && $signup_type != 'anon') {
    $submission = signup_webform_get_signup_submission($signup, $webform_nid);
  }
  $component_tree = array();
  $page_count = 1;
  $page_num = 1;
  _webform_components_tree_build($webform_node->webform['components'], $component_tree, 0, $page_count);

  //dsm($component_tree);

  // Recursively add components to the form. Microweights keep things in webform order.
  // No idea what most of these do; _webform_client_form_add_component() is an undocumented black box!
  $microweight = 0.001;
  $enabled = TRUE;
  foreach ($component_tree['children'] as $cid => $component) {

    // we have no existing values here ever.
    $component_value = NULL;
    _webform_client_form_add_component($cid, $component, $component_value, $form, $form, $submission, $page_num, $enabled);
  }
  return $form;
}