Reputation: 29
I'm adding a form element like so:
$this->addElement('text', 'product_name', array(
'label' => 'product name',
'... )
);
I'd like to reference the product_name
label in the ViewScript
decorator script as I'm doing it with product_name
text input <?php echo $this->form->product_name; ?>
but the label tag rendered by the "addElement" have no "name" attribute. How can I solve the problem?
Upvotes: 0
Views: 86
Reputation: 3310
Option 1: Use Zend manual and check out the section "Rendering Individual decorators" to see how to render your label alone.
Option 2: You can skip the label part, remove its decorator in the form code as follows, and then add it in the form's view script directly with styles you want to add:
$element = new Zend_Form_Element_Text('product_name');
$element->removeDecorator('HtmlTag')
->removeDecorator('Label');
Then, in the view script:
<span class="label"> Product Name: </span> <?php echo $this->form->product_name; ?>
Upvotes: 0