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

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>