Add maximum age restriction to registration form

This commit is contained in:
2015-03-18 11:53:52 +11:00
parent 034785d70c
commit 5aa285e9dc
4 changed files with 88 additions and 23 deletions

View File

@@ -49,26 +49,6 @@ function booking_register_page() {
return $return_array;
}
/**
* Landing page after returning from paypal
*/
function booking_payment_completed_page() {
//get some configuration information
global $event;
$output = "";
$return_array = array();
//set the page title
$bookingTitle = !empty($event->booking_eventname) ? $event->booking_eventname : 'Event';
drupal_set_title($bookingTitle . ' Registration Completed');
$output = token_replace(variable_get('booking_regn_completed_page'), booking_define_tokens());
$return_array[] = array('paragraph' => array('#type' => 'markup', '#markup' => $output));
return $return_array;
}
function booking_form($node, &$form_state, $inserting = FALSE) {
global $event;
@@ -77,6 +57,12 @@ function booking_form($node, &$form_state, $inserting = FALSE) {
$partner_options = array();
date_default_timezone_set(date_default_timezone(FALSE));
//calculate what years to show in the date of birth field
$min_dob_years = _booking_year_offset(variable_get('booking_min_dob','1970-01-01 00:00:00'));
$max_dob_years = _booking_year_offset(variable_get('booking_max_dob','1970-01-01 00:00:00'));
$date_year_range = "-" . $min_dob_years . ':-' . $max_dob_years;
//determine whether loading saved node or form submission
if (!empty($node))
{
$data = $node;
@@ -93,11 +79,13 @@ function booking_form($node, &$form_state, $inserting = FALSE) {
'legal_guardian' => 'Legal Guardian',
'relative' => 'Close Relative');
/*
$status_options[0] = t('Not Paid');
$status_options[1] = t('Booked In');
$status_options[2] = t('Waiting List');
$status_options[3] = t('No Longer Coming');
*/
//figure out if we're in the earlybird rate section
$early = db_query("SELECT booking_earlybird_close FROM {booking_event} where eid = :eid", array(
':eid' => $event->eid))
@@ -158,8 +146,14 @@ function booking_form($node, &$form_state, $inserting = FALSE) {
'#date_format' => 'd/m/Y',
'#date_label_position' => 'within',
'#date_year_range' => '-50:-13'
//'#date_year_range' => $date_year_range,
);
//override our generous date year range if this is a new form submission
if ($inserting == TRUE) {
$form['your-details']['booking_dob']['#date_year_range'] = $date_year_range;
}
$form['your-details']['booking_payment_id'] = array(
'#type' => 'select',
'#title' => t('Choose your payment type'),
@@ -1265,3 +1259,24 @@ function _booking_form_submit_post_triggers($node) {
}
}
/**
* Landing page after returning from paypal
*/
function booking_payment_completed_page() {
//get some configuration information
global $event;
$output = "";
$return_array = array();
//set the page title
$bookingTitle = !empty($event->booking_eventname) ? $event->booking_eventname : 'Event';
drupal_set_title($bookingTitle . ' Registration Completed');
$output = token_replace(variable_get('booking_regn_completed_page'), booking_define_tokens());
$return_array[] = array('paragraph' => array('#type' => 'markup', '#markup' => $output));
return $return_array;
}