better form validation for rebroadcast date/times

This commit is contained in:
Naomi 2011-04-15 10:23:08 -04:00
parent c3a02e2569
commit 0982405d4c
2 changed files with 21 additions and 3 deletions

View File

@ -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);

View File

@ -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];