2011-01-21 00:30:53 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
class Application_Form_AddShowWhen extends Zend_Form_SubForm
|
|
|
|
{
|
|
|
|
|
|
|
|
public function init()
|
|
|
|
{
|
|
|
|
// Add start date element
|
2011-01-21 19:25:12 +01:00
|
|
|
$this->addElement('text', 'add_show_start_date', array(
|
2011-01-21 00:30:53 +01:00
|
|
|
'label' => 'Date Start:',
|
2011-01-31 02:11:18 +01:00
|
|
|
'class' => 'input_text',
|
2011-01-21 00:30:53 +01:00
|
|
|
'required' => true,
|
|
|
|
'filters' => array('StringTrim'),
|
|
|
|
'validators' => array(
|
|
|
|
'NotEmpty',
|
|
|
|
array('date', false, array('YYYY-MM-DD'))
|
|
|
|
)
|
|
|
|
));
|
|
|
|
|
|
|
|
// Add start time element
|
2011-01-21 19:25:12 +01:00
|
|
|
$this->addElement('text', 'add_show_start_time', array(
|
2011-01-21 00:30:53 +01:00
|
|
|
'label' => 'Start Time:',
|
2011-01-28 23:37:31 +01:00
|
|
|
'class' => 'input_text',
|
2011-01-21 00:30:53 +01:00
|
|
|
'required' => true,
|
|
|
|
'filters' => array('StringTrim'),
|
|
|
|
'validators' => array(
|
|
|
|
'NotEmpty',
|
|
|
|
array('date', false, array('HH:mm'))
|
|
|
|
)
|
|
|
|
));
|
|
|
|
|
|
|
|
// Add duration element
|
2011-01-21 19:25:12 +01:00
|
|
|
$this->addElement('text', 'add_show_duration', array(
|
2011-01-21 00:30:53 +01:00
|
|
|
'label' => 'Duration:',
|
2011-01-28 23:37:31 +01:00
|
|
|
'class' => 'input_text',
|
2011-01-21 00:30:53 +01:00
|
|
|
'required' => true,
|
|
|
|
'filters' => array('StringTrim'),
|
|
|
|
'validators' => array(
|
|
|
|
'NotEmpty',
|
|
|
|
array('date', false, array('HH:mm'))
|
|
|
|
)
|
|
|
|
));
|
|
|
|
|
|
|
|
// Add repeats element
|
2011-01-21 19:25:12 +01:00
|
|
|
$this->addElement('checkbox', 'add_show_repeats', array(
|
2011-01-21 00:30:53 +01:00
|
|
|
'label' => 'repeats',
|
|
|
|
'required' => false,
|
|
|
|
));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2011-01-31 02:11:18 +01:00
|
|
|
public function checkReliantFields($formData) {
|
2011-01-28 23:37:31 +01:00
|
|
|
|
|
|
|
$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;
|
|
|
|
}
|
2011-01-21 00:30:53 +01:00
|
|
|
|
|
|
|
}
|
|
|
|
|