I'm in the process of switching my forms to use a View Script as their decorators. The examples I've seen so far do the following in the View Script:
<td><label for='textEmail'>Email:</label></td>
<td><?php echo $this->element->textEmail; ?></td>
I would like to find a way to have the text to be displayed in the label from the Form Object as well.
class RegisterForm extends Zend_Form {
public function init () {
$this->setAction('')
->setMethod('post')
->setAttrib('id','formRegister');
$this->addElement('text', 'textEmail', array('label' => 'Email: '));
$oEmail = $this->getElement('textEmail')
->setRequired(true)
->addFilter('StringTrim')
->addValidator('EmailAddress');
$oEmail->setDecorators(array('ViewHelper', 'Errors'));
$this->setDecorators(array(array('ViewScript', array('viewScript' => 'forms/RegisterForm.phtml'))));
}
}
Above is how my Form Object is defined. Is anyone aware of how to access the defined label value? In the following format perhaps?
<?php echo $this->element->textEmail->label; ?>
Naturally that doesn't work. :p Thanks~