CC-2933: Add From When: Create custom decorator(phtml) for

the section

- done
This commit is contained in:
James 2011-10-05 12:22:54 -04:00
parent b90b69ebde
commit 75f57fc18c
2 changed files with 77 additions and 20 deletions

View File

@ -5,6 +5,10 @@ class Application_Form_AddShowWhen extends Zend_Form_SubForm
public function init()
{
$this->setDecorators(array(
array('ViewScript', array('viewScript' => 'form/add-show-when.phtml'))
));
// Add start date element
$startDate = new Zend_Form_Element_Text('add_show_start_date');
$startDate->class = 'input_text';
@ -15,11 +19,7 @@ class Application_Form_AddShowWhen extends Zend_Form_SubForm
->setValidators(array(
'NotEmpty',
array('date', false, array('YYYY-MM-DD'))))
->setDecorators(array(
array(array('open'=>'HtmlTag'), array('tag' => 'dd', 'openOnly'=>true)),
'ViewHelper',
'Description',
array('Label', array('tag' =>'dt'))));
->setDecorators(array('ViewHelper'));
$startDate->setAttrib('alt', 'date');
$this->addElement($startDate);
@ -33,10 +33,7 @@ class Application_Form_AddShowWhen extends Zend_Form_SubForm
'NotEmpty',
array('date', false, array('HH:mm')),
array('regex', false, array('/^[0-9:]+$/', 'messages' => 'Invalid character entered'))))
->setDecorators(array(
'ViewHelper',
'Errors',
array(array('close'=>'HtmlTag'), array('tag' => 'dd', 'closeOnly'=>true))));
->setDecorators(array('ViewHelper'));
$startTime->setAttrib('alt', 'time');
$this->addElement($startTime);
@ -50,11 +47,7 @@ class Application_Form_AddShowWhen extends Zend_Form_SubForm
->setValidators(array(
'NotEmpty',
array('date', false, array('YYYY-MM-DD'))))
->setDecorators(array(
array(array('open'=>'HtmlTag'), array('tag' => 'dd', 'openOnly'=>true)),
'ViewHelper',
'Description',
array('Label', array('tag' =>'dt'))));
->setDecorators(array('ViewHelper'));
$endDate->setAttrib('alt', 'date');
$this->addElement($endDate);
@ -68,10 +61,7 @@ class Application_Form_AddShowWhen extends Zend_Form_SubForm
'NotEmpty',
array('date', false, array('HH:mm')),
array('regex', false, array('/^[0-9:]+$/', 'messages' => 'Invalid character entered'))))
->setDecorators(array(
'ViewHelper',
'Errors',
array(array('close'=>'HtmlTag'), array('tag' => 'dd', 'closeOnly'=>true))));
->setDecorators(array('ViewHelper'));
$endTime->setAttrib('alt', 'time');
$this->addElement($endTime);
@ -80,20 +70,22 @@ class Application_Form_AddShowWhen extends Zend_Form_SubForm
'label' => 'Duration:',
'class' => 'input_text',
'value' => '01h00m',
'readonly' => true
'readonly' => true,
'decorators' => array('ViewHelper')
));
// Add repeats element
$this->addElement('checkbox', 'add_show_repeats', array(
'label' => 'Repeats?',
'required' => false,
'decorators' => array('ViewHelper')
));
}
public function checkReliantFields($formData, $startDateModified) {
$valid = true;
$start_time = $formData['add_show_start_date']." ".$formData['add_show_start_time'];
//DateTime stores $start_time in the current timezone

View File

@ -0,0 +1,65 @@
<fieldset>
<dl>
<dt id="add_show_start_date-label">
<label for="add_show_start_date" class="required">
<?php echo $this->element->getElement('add_show_start_date')->getLabel()?>
</label>
</dt>
<dd>
<?php echo $this->element->getElement('add_show_start_date') ?>
<?php echo $this->element->getElement('add_show_start_time') ?>
</dd>
<?php if($this->element->getElement('add_show_start_date')->hasErrors() || $this->element->getElement('add_show_start_time')->hasErrors()){ ?>
<ul class='errors'>
<?php foreach($this->element->getElement('add_show_start_date')->getMessages() as $error): ?>
<li><?php echo $error; ?></li>
<?php endforeach; ?>
<?php foreach($this->element->getElement('add_show_start_time')->getMessages() as $error): ?>
<li><?php echo $error; ?></li>
<?php endforeach; ?>
</ul>
<?php } ?>
<dt id="add_show_end_date_no_repeat-label">
<label for="add_show_end_date_no_repeat" class="required">
<?php echo $this->element->getElement('add_show_end_date_no_repeat')->getLabel()?>
</label>
</dt>
<dd>
<?php echo $this->element->getElement('add_show_end_date_no_repeat') ?>
<?php echo $this->element->getElement('add_show_end_time') ?>
</dd>
<?php if($this->element->getElement('add_show_end_date_no_repeat')->hasErrors() || $this->element->getElement('add_show_end_time')->hasErrors()){ ?>
<ul class='errors'>
<?php foreach($this->element->getElement('add_show_end_date_no_repeat')->getMessages() as $error): ?>
<li><?php echo $error; ?></li>
<?php endforeach; ?>
<?php foreach($this->element->getElement('add_show_end_time')->getMessages() as $error): ?>
<li><?php echo $error; ?></li>
<?php endforeach; ?>
</ul>
<?php } ?>
<dt id="add_show_duration-label">
<label for="add_show_duration" class="optional">
<?php echo $this->element->getElement('add_show_duration')->getLabel() ?>
</label>
</dt>
<dd id="add_show_duration-element">
<?php echo $this->element->getElement('add_show_duration') ?>
</dd>
<?php if($this->element->getElement('add_show_duration')->hasErrors()){ ?>
<ul class='errors'>
<?php foreach($this->element->getElement('add_show_duration')->getMessages() as $error): ?>
<li><?php echo $error; ?></li>
<?php endforeach; ?>
</ul>
<?php } ?>
<dt id="add_show_repeats-label">
<?php echo $this->element->getElement('add_show_repeats')->getLabel() ?>
</dt>
<dd id="add_show_repeats-element">
<?php echo $this->element->getElement('add_show_repeats') ?>
</dd>
</dl>
</fieldset>