From 3cfca677ea5c79442febb6717b3b302ed08b574b Mon Sep 17 00:00:00 2001 From: Nathan Coad Date: Thu, 3 May 2018 08:29:58 +1000 Subject: [PATCH] improve validate --- booking.variety_form.inc | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/booking.variety_form.inc b/booking.variety_form.inc index 9828e4d..a420fe8 100644 --- a/booking.variety_form.inc +++ b/booking.variety_form.inc @@ -167,6 +167,13 @@ function booking_variety_regn_form_validate($form, &$form_state) { //check there is still room foreach ($variety_timeslot_ids as $id) { $selected_session_id = $values['select-variety-' . $id]; + + // Don't try and check availablity for a select element that is still on the default value + if ($selected_session_id == 0) { + form_set_error('select-variety-' . $id, t('You have not selected a variety session.')); + continue; + } + $session = $sessions[$selected_session_id]; if ($session->booking_variety_regncount < $session->booking_variety_maxsize) { watchdog('booking_debug', 'Still room in session @id : @count is less than @size', array(