function signup_form in Signup 6.2
Same name and namespace in other branches
- 5.2 signup.module \signup_form()
- 5 signup.module \signup_form()
- 6 includes/signup_form.inc \signup_form()
- 7 includes/signup_form.inc \signup_form()
Build the user signup form.
Parameters
$node: The fully loaded node object.
$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).
$fieldset: Boolean that indicates if the signup form should be in a fieldset.
4 string references to 'signup_form'
- signup_confirm_email_alter_signup_form in modules/
signup_confirm_email/ signup_confirm_email.inc - Alter the signup form to add the e-mail confirmation functionality.
- signup_confirm_email_form_alter in modules/
signup_confirm_email/ signup_confirm_email.module - Implement hook_form_alter().
- signup_node_admin_add_user_page in includes/
signup_form.inc - _signup_current_user_signup in includes/
node_output.inc - Helper function to generate the output for the current user's signup.
File
- includes/
signup_form.inc, line 22 - Code for the form when users sign up.
Code
function signup_form(&$form_state, $node, $signup_type = 'auth', $fieldset = TRUE) {
global $user;
$form = array();
$form['nid'] = array(
'#type' => 'value',
'#value' => $node->nid,
);
$form['uid'] = array(
'#type' => 'value',
'#value' => $user->uid,
);
if ($fieldset) {
$form['collapse'] = array(
'#type' => 'fieldset',
'#collapsible' => TRUE,
'#collapsed' => variable_get('signup_fieldset_collapsed', 1),
);
if ($signup_type == 'admin') {
$form['collapse']['#title'] = t('Sign up another user');
// We always want this fieldset expanded on the node/N/signups tab.
$form['collapse']['#collapsed'] = FALSE;
}
else {
$form['collapse']['#title'] = t('Sign up for @title', array(
'@title' => $node->title,
));
}
}
else {
$form['collapse'] = array();
}
$signup_form = array();
if ($signup_type == 'anon') {
$anon_form = array();
$anon_form['signup_anon_mail'] = array(
'#type' => 'textfield',
'#title' => t('Email'),
'#description' => t('An e-mail address is required for users who are not registered at this site. If you are a registered user at this site, please !login to sign up for this %node_type.', array(
'!login' => l(t('login'), 'user/login', array(
'query' => drupal_get_destination(),
)),
'%node_type' => node_get_types('name', $node->type),
)),
'#size' => 40,
'#maxlength' => 255,
'#required' => TRUE,
);
$validate_handler = 'signup_form_validate_anon';
$signup_form += $anon_form;
}
elseif ($signup_type == 'admin') {
$admin_form = array();
$admin_form['signup_username'] = array(
'#title' => t('Username'),
'#type' => 'textfield',
'#autocomplete_path' => 'user/autocomplete',
'#maxlength' => USERNAME_MAX_LENGTH,
'#size' => 40,
'#weight' => -1,
'#required' => TRUE,
);
$validate_handler = 'signup_form_validate_username';
$signup_form += $admin_form;
}
// Insert the form components provided by other modules.
if (isset($node->signup_form_panes)) {
$signup_form['signup_form_data'] = array(
'#tree' => TRUE,
);
// Add each pane to the form. The node settings are stored in the weighted
// order so there is no need for further sorting here.
foreach ($node->signup_form_panes as $pane_id => $pane_data) {
$callback = $pane_data['callback'];
if (function_exists($callback)) {
// Each pane goes into its own form element with #tree set
// to protect form values from clashing.
$signup_form['signup_form_data'][$pane_id] = array(
'#tree' => TRUE,
);
// Add a validation function for each pane.
$signup_form['signup_form_data']['#element_validate'][] = $callback . '_validate';
$signup_form['signup_form_data'][$pane_id] += $callback($signup_form, $form_state, $node, NULL, $pane_id, $signup_type);
}
}
}
$form['collapse']['signup_user_form'] = $signup_form;
$form['collapse']['submit'] = array(
'#type' => 'submit',
'#value' => t('Sign up'),
);
if (!empty($validate_handler)) {
$form['#validate'][] = $validate_handler;
}
return $form;
}