From 0982405d4c20d9a2860481548e683c8ede78bc6e Mon Sep 17 00:00:00 2001 From: Naomi Date: Fri, 15 Apr 2011 10:23:08 -0400 Subject: [PATCH] better form validation for rebroadcast date/times --- .../forms/AddShowAbsoluteRebroadcastDates.php | 11 ++++++++++- .../application/forms/AddShowRebroadcastDates.php | 13 +++++++++++-- 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/airtime_mvc/application/forms/AddShowAbsoluteRebroadcastDates.php b/airtime_mvc/application/forms/AddShowAbsoluteRebroadcastDates.php index bb3c79125..812861744 100644 --- a/airtime_mvc/application/forms/AddShowAbsoluteRebroadcastDates.php +++ b/airtime_mvc/application/forms/AddShowAbsoluteRebroadcastDates.php @@ -38,9 +38,14 @@ class Application_Form_AddShowAbsoluteRebroadcastDates extends Zend_Form_SubForm $day = $formData['add_show_rebroadcast_date_absolute_'.$i]; - if(trim($day) == "") { + if(trim($day) == "" && trim($time) == "") { continue; } + + if (trim($day) == ""){ + $this->getElement('add_show_rebroadcast_date_absolute_'.$i)->setErrors(array("Day must be specified")); + $valid = false; + } $time = $formData['add_show_rebroadcast_time_absolute_'.$i]; if (trim($time) == ""){ @@ -48,6 +53,10 @@ class Application_Form_AddShowAbsoluteRebroadcastDates extends Zend_Form_SubForm $valid = false; } + if($valid === false) { + return false; + } + $show_start_time = $formData['add_show_start_date']."".$formData['add_show_start_time']; $show_end = new DateTime($show_start_time); diff --git a/airtime_mvc/application/forms/AddShowRebroadcastDates.php b/airtime_mvc/application/forms/AddShowRebroadcastDates.php index e51bcf570..0ced37cc5 100644 --- a/airtime_mvc/application/forms/AddShowRebroadcastDates.php +++ b/airtime_mvc/application/forms/AddShowRebroadcastDates.php @@ -39,13 +39,18 @@ class Application_Form_AddShowRebroadcastDates extends Zend_Form_SubForm $valid = true; - for($i=1; $i<=5; $i++) { + for($i=1; $i<=10; $i++) { $days = $formData['add_show_rebroadcast_date_'.$i]; - if(trim($days) == "") { + if(trim($days) == "" && trim($time) == "") { continue; } + + if (trim($days) == ""){ + $this->getElement('add_show_rebroadcast_date_'.$i)->setErrors(array("Day must be specified")); + $valid = false; + } $time = $formData['add_show_rebroadcast_time_'.$i]; if (trim($time) == ""){ @@ -53,6 +58,10 @@ class Application_Form_AddShowRebroadcastDates extends Zend_Form_SubForm $valid = false; } + if($valid === false) { + return false; + } + $days = explode(" ", $days); $day = $days[0];