function signup_form in Signup 5.2
Same name and namespace in other branches
- 5 signup.module \signup_form()
- 6.2 includes/signup_form.inc \signup_form()
- 6 includes/signup_form.inc \signup_form()
- 7 includes/signup_form.inc \signup_form()
Builder function for the 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.
2 string references to 'signup_form'
- signup_node_admin_page in ./
signup.module - Prints the signup details for a single node when the signups tab is clicked
- _signup_node_output in ./
signup.module - Generate all the signup-related output for a given node.
File
- ./
signup.module, line 1090 - The Signup module (http://drupal.org/project/signup) manages replies to nodes. In particular, it's good for event management. Signup supports sending reminder emails and automatically closing signups for nodes with a start time, via the Event…
Code
function signup_form($node, $signup_type = 'auth', $fieldset = TRUE) {
global $user;
require_once SIGNUP_PATH . '/theme/signup.theme';
$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(), drupal_get_destination()),
'%node_type' => node_get_types('name', $node->type),
)),
'#size' => 40,
'#validate' => array(
'signup_form_validate_anon' => array(
$node->nid,
),
),
'#maxlength' => 255,
'#required' => TRUE,
);
$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,
'#validate' => array(
'signup_form_validate_username' => array(
$node->nid,
),
),
'#size' => 40,
'#weight' => -1,
'#required' => TRUE,
);
$signup_form += $admin_form;
}
// Build the themed signup form for this site and include that.
$signup_themed_form = theme('signup_user_form', $node);
if ($signup_type == 'admin') {
// Special case hack for the default signup form, where the current
// username is being filled in as the default for the 'Name' field.
if (!empty($signup_themed_form['signup_form_data']['Name']['#default_value'])) {
unset($signup_themed_form['signup_form_data']['Name']['#default_value']);
}
}
$signup_form += $signup_themed_form;
$form['collapse']['signup_user_form'] = $signup_form;
$form['collapse']['submit'] = array(
'#type' => 'submit',
'#value' => t('Sign up'),
);
return $form;
}