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

@ -26,6 +26,7 @@ class Application_Form_AddShowRepeats extends Zend_Form_SubForm
// Add end date element
$this->addElement('text', 'add_show_end_date', array(
'label' => 'Date End:',
//'class' => 'input_text hasDatepicker',
'required' => false,
'filters' => array('StringTrim'),
'validators' => array(

View file

@ -8,12 +8,14 @@ class Application_Form_AddShowStyle extends Zend_Form_SubForm
// Add show background-color input
$this->addElement('text', 'add_show_background_color', array(
'label' => 'Background Colour:',
'class' => 'input_text',
'filters' => array('StringTrim')
));
// Add show color input
$this->addElement('text', 'add_show_color', array(
'label' => 'Text Colour',
'class' => 'input_text',
'filters' => array('StringTrim')
));
}

View file

@ -8,15 +8,25 @@ class Application_Form_AddShowWhat extends Zend_Form_SubForm
// Add name element
$this->addElement('text', 'add_show_name', array(
'label' => 'Name:',
'class' => 'input_text',
'required' => true,
'filters' => array('StringTrim'),
'validators' => array('NotEmpty')
));
$nameLabel = $this->getElement('add_show_name');
$nameLabel->setDecorators(array(array('ViewScript', array(
'viewScript' => 'testform.phtml',
'class' => 'test template'
))));
// Add the description element
$this->addElement('textarea', 'add_show_description', array(
'label' => 'Description:',
'required' => false,
'class' => 'input_text_area'
));
}

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;
}
}

View file

@ -8,6 +8,7 @@ class Application_Form_AddShowWho extends Zend_Form_SubForm
// Add hosts autocomplete
$this->addElement('text', 'add_show_hosts_autocomplete', array(
'label' => 'Type a Host:',
'class' => 'input_text ui-autocomplete-input',
'required' => false
));