-- Jonathan Tullett <[EMAIL PROTECTED]> wrote
(on Wednesday, 07 May 2008, 06:45 AM -0700):
>
> Hello.
>
> I've been playing with Zend_Form today, specifically with the text
> decorators, however it's not behaving quite how I expect.
>
> I've extended the Zend_Form class, and I create the form using an array of
> options, like so:
<snip>
> What's happening is that the specific element decorate is being overridden
> due to the setOptions method in Zend/Form.php doing this:
> $this->setElementDecorators($elementDecorators);
>
> after all the elements are set. This is causing my specific element
> decorators to be overridden.
>
> Does anyone have any ideas on how I can do what I'm wanting while staying
> with this method of form configuration?
Zend_Form::setOptions() delays the setElementDecorators() call to after
all other configuration, so that any elements set using configuration
will then be affected by it. There is no way to override it.
An easier approach is to define an array of default decorators you want
to use as an class property:
public $defaultElementDecorators = array(...);
Then, omit your elementDecorators declaration, and declare your
decorators for each element by referencing this property:
'foo' => array(
'decorators' => $this->defaultElementDecorators
),
For elements where you want custom decorators, you do as you were doing
previously.
--
Matthew Weier O'Phinney
Software Architect | [EMAIL PROTECTED]
Zend - The PHP Company | http://www.zend.com/