some basic form work, need to lear more about custom form validation/rendering.

This commit is contained in:
Naomi 2011-01-28 17:37:31 -05:00
parent 381cdc11a9
commit 10d9d13993
11 changed files with 791 additions and 619 deletions

View file

@ -8,6 +8,7 @@ class Application_Form_AddShowWhen extends Zend_Form_SubForm
// Add start date element
$this->addElement('text', 'add_show_start_date', array(
'label' => 'Date Start:',
//'class' => 'input_text hasDatepicker',
'required' => true,
'filters' => array('StringTrim'),
'validators' => array(
@ -19,6 +20,7 @@ class Application_Form_AddShowWhen extends Zend_Form_SubForm
// Add start time element
$this->addElement('text', 'add_show_start_time', array(
'label' => 'Start Time:',
'class' => 'input_text',
'required' => true,
'filters' => array('StringTrim'),
'validators' => array(
@ -30,6 +32,7 @@ class Application_Form_AddShowWhen extends Zend_Form_SubForm
// Add duration element
$this->addElement('text', 'add_show_duration', array(
'label' => 'Duration:',
'class' => 'input_text',
'required' => true,
'filters' => array('StringTrim'),
'validators' => array(
@ -46,6 +49,21 @@ class Application_Form_AddShowWhen extends Zend_Form_SubForm
}
public function postValidation(array $formData) {
$now_timestamp = date("Y-m-d H:i:s");
$start_timestamp = $formData['add_show_start_date']."".$formData['add_show_start_time'];
$now_epoch = strtotime($now_timestamp);
$start_epoch = strtotime($start_timestamp);
if($start_epoch < $now_epoch) {
$this->getElement('add_show_start_time')->setErrors(array('Cannot create show in the past'));
return false;
}
return true;
}
}