From 47fcbd04f2b00869b48bfae99be2b968bb0ad6f8 Mon Sep 17 00:00:00 2001 From: Nathan Coad Date: Tue, 10 Sep 2019 09:49:26 +1000 Subject: [PATCH] update form to ask previous sw question --- booking.constants.inc | 14 +++++++++++++- booking.regn_form.inc | 9 +++++++++ booking.regn_node.inc | 6 +++++- 3 files changed, 27 insertions(+), 2 deletions(-) diff --git a/booking.constants.inc b/booking.constants.inc index 1b14489..4c2986a 100644 --- a/booking.constants.inc +++ b/booking.constants.inc @@ -130,7 +130,19 @@ function _get_tshirt_options() { return $options_array; } - +/** + * Helper function to provide a list of options for the previous study week count field of the registration form + */ +function _get_previous_sw_options() { + $options_array = array(); + $options_array[''] = ''; + + for ($i = 0; $i < 6; $i++) { + $options_array[$i] = $i; + } + + return $options_array; +} /** * Helper function to look up description of studygroup role diff --git a/booking.regn_form.inc b/booking.regn_form.inc index dbf21b3..e3dc3c4 100644 --- a/booking.regn_form.inc +++ b/booking.regn_form.inc @@ -957,6 +957,15 @@ function booking_form($node, &$form_state, $inserting = FALSE) '#default_value' => !empty($data->booking_freestyle_text) ? $data->booking_freestyle_text : '' ); } + if (variable_get('booking_enable_previous_studyweeks', 0) == 1) { + $form['misc-areas']['booking_prev_sw_count'] = array( + '#type' => 'select', + '#title' => t("How many Study Weeks have you been to previously?"), + '#required' => FALSE, + '#default_value' => variable_get('booking_prev_sw_count', empty($data->booking_prev_sw_count) ? '' : $data->booking_prev_sw_count), + '#options' => _get_previous_sw_options(), + ); + } // https://www.lullabot.com/articles/a-beginners-guide-to-caching-data-in-drupal-7 // This code will only cache this one element diff --git a/booking.regn_node.inc b/booking.regn_node.inc index e4c62a8..43c468d 100644 --- a/booking.regn_node.inc +++ b/booking.regn_node.inc @@ -412,7 +412,8 @@ function booking_update($node) { 'booking_welfare_required', 'booking_payment_complete', 'booking_refund_processed', 'booking_committee_member' ); //these fields should be zero if not defined - $default_zero_keys = array('booking_luckynum', 'booking_bf_gf_nid', 'booking_keepseparate_id', 'booking_refund_due', 'booking_earlyaccess_code_id'); + $default_zero_keys = array('booking_luckynum', 'booking_bf_gf_nid', 'booking_keepseparate_id', 'booking_refund_due', 'booking_earlyaccess_code_id', + 'booking_prev_sw_count'); //some fields are present in $node from the SQL view we use that don't belong in booking_person so exclude them $excluded_keys = array('booking_person_nid', 'booking_transport_type', 'booking_transport_from_morriset_reqd', 'booking_transport_to_morriset_reqd', @@ -893,6 +894,9 @@ function booking_view($node, $view_mode) { if (variable_get('booking_enable_freestyle', 0) == 1) { $rows[] = array(t('Freestyle:'), t('!song', array('!song' => $node->booking_freestyle_text))); } + if (variable_get('booking_enable_previous_studyweeks', 0) == 1) { + $rows[] = array(t('Number of previous SW:'), t('!sw', array('!sw' => $node->booking_prev_sw_count))); + } if (variable_get('booking_enable_tshirts', 0) == 1) { $rows[] = array(t('Hoodie Size:'), t('!size', array('!size' => $node->booking_shirt_size))); }