-- Vytautas Jakutis <[EMAIL PROTECTED]> wrote
(on Friday, 07 March 2008, 10:10 PM +0200):
> In 1.5.0RC1 is there a good way to add a decorator when creating a form
> with Zend_Config, without clearing the default ones?
No. Passing the decorators during instantiation calls setDecorators(),
which overwrites, and also prevents loadDefaultDecorators() from
triggering.
You will need to extend Zend_Form and/or your element classes to modify
that behavior, much as you've done below.
> for example: I want this this to add a decorator and preserve the default.
> Currently, this clears them.
> elements.firstname.options.decorators.link.type = "Callback"
> elements.firstname.options.decorators.link.options.callback =
> "my_decorator_callback_link"
>
> I've attached a patch for Zend/Form/Element.php which I currently use
> --- Zend/Form/Element.orig.php 2008-03-07 21:58:28.000000000 +0200
> +++ Zend/Form/Element.php 2008-03-07 21:58:48.000000000 +0200
> @@ -222,12 +222,12 @@
> protected function _loadDefaultDecorators()
BTW, it's clear from the above that you're not using current trunk, as I
changed the visibility of this method to public and renamed it to
loadDefaultDecorators(). ;-)
Additionally, there's now a flag that allows you to suppress loading the
default decorators that this method now takes into account.
> {
> $decorators = $this->getDecorators();
> - if (empty($decorators)) {
> +// if (empty($decorators)) {
> $this->addDecorator('ViewHelper')
> ->addDecorator('Errors')
> ->addDecorator('HtmlTag', array('tag' => 'dd'))
> ->addDecorator('Label', array('tag' => 'dt'));
> - }
> +// }
> }
>
> /**
--
Matthew Weier O'Phinney
PHP Developer | [EMAIL PROTECTED]
Zend - The PHP Company | http://www.zend.com/