I recommend creating a form wide decorator that meets the need of each element.
Here's an example:
class Core_Form_NewAccount extends ZF_form
{
public $textDecorators = array('ViewHelper', array(array('data' =>
'HtmlTag'), array('tag' => 'dd')), array('Label', array('tag' => 'dt')),
array('HtmlTag', array('tag' => 'dl')));
$this->addElement('text', 'fname', array(
'label' => '*First Name',
'required' => true,
'decorators' => $this->textDecorators
));
You may need to use 'decorators' => self::$textDecorators if it is a real
subForm but other than that, not sure why you'd have an issue. There should
"decorate", therefore build onto the output of your form class.
-Wil
-----Original Message-----
From: Mike Wright [mailto:[email protected]]
Sent: Sunday, November 27, 2011 4:08 PM
To: [email protected]
Subject: Re: [fw-general] RE: desperately need help with decorators
On 11/26/2011 02:03 PM, Razorblade wrote:
> Hi,
> try also this solution:
>
> protected $_formElementDecorators = array(
> 'ViewHelper',
> array( 'Errors', array('escape' => false, 'placement' => 'append' ) ),
> array( array( 'containerDD' => 'HtmlTag' ), array('tag' => 'dd') ),
> array( 'Label', array('tag' => 'dt', 'escape' => false ) ),
> array( array('row' => 'HtmlTag'), array('tag' => 'dl' ) ), );
>
> It's the same solution of Wil Revehl, but adds error management.
> The error tag, if any, will be rendered right after the "input" html tag.
>
> You must call
> $this->setElementDecorators($this->_formElementDecorators);
> after you defined all your elements.
>
> The properties of the Errors decorator ( array('escape' => false,
> 'placement' => 'append' ) ) are there just to let you know they exists.
>
> Hope it helps.
Razorblade, Wilson Revehl,
Helpful and insightful.
I now have this...
$subForm->setElementDecorators(array(
array(array('dd' => 'HtmlTag'), array('tag' => 'dd')),
array(array('dt' => 'Label'), array('tag' => 'dt')),
array(array('dl' => 'HtmlTag'), array('tag' => 'dl')),
));
$subForm->setDecorators(array(
array('elem' => 'FormElements'),
array('form' => 'Form'),
array('fset' => 'Fieldset'),
));
... which gives perfect markup.
Problem is the <dt><label> tag is fully populated but the corresponding <dd> is
empty.
The labels are there, where are the matching form elements?
--
List: [email protected]
Info: http://framework.zend.com/archives
Unsubscribe: [email protected]
--
List: [email protected]
Info: http://framework.zend.com/archives
Unsubscribe: [email protected]