I don't know whether you have seen or read Matthew's article on devzone, but
it proved to be an invaluable resource to me when trying to understand the
usage of the Decorator pattern in Zend_Form. Take a look if you haven't
already:

http://devzone.zend.com/article/3450-Decorators-with-Zend_Form

The article states:

"The standard decorators, in the order they are registered, for most
elements are:"

- ViewHelper
- Errors
- HtmlTag (<dd>)
- Label (with wrapping <dt> tag)

Of course for the Hash element you don't want the errors. While there are
other ways to skin this cat, what I did was to create a custom element like
so:

class My_Form_Element_Hash extends Zend_Form_Element_Hash
{
    public function loadDefaultDecorators()
    {
        $this->setDecorators(
            array(
                'ViewHelper',
                'HtmlTag',
            )
        );
    }

}

If you take this approach then you also need to tell the form how to locate
your custom element(s):

$form->addPrefixPath('My_Form_Element', 'My/Form/Element/', 'element');


dowker wrote:
> 
> I use a single composite decorator for many of my forms. I find it much 
> easier to work with since most forms for a given project are similar. 
> I'm simply trying to add a Zend_Form_Element_Hash field to a "Contact 
> Us" form on one of my websites.
> 
> I've built up the form and everything works fine with the standard 
> decorators. As soon as I implement my custom decorator, when I submit 
> the form, I get the error "No token was provided to match against" and I 
> can't seem to find the difference between the standard decorators and my 
> custom composite decorator.
> 
> Would anyone know why this is happening or could you point me in the 
> right direction?
> 
> Thanks.
> 
> 

-- 
View this message in context: 
http://www.nabble.com/Zend_Form_Element_Hash-tp19421913p19428568.html
Sent from the Zend Framework mailing list archive at Nabble.com.

Reply via email to