Quantcast

Zend Decorator setOption() Error

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Zend Decorator setOption() Error

apollox
Hi, i have at the moment a little problem in my project with the Zend Form Decorator. I want that the label elements of my forms have no
tag arround, because I want to display the complete form with other layout . My Code for that is the following: foreach ($form->getElements() as $element) { $element->getDecorator('label')->setOption('tag', null); } But then I got only the following error: Fatal error: Call to a member function setOption() on a non-object And that I do not understand, because the return of getDecorator() is an object from Zend_Form_Decorator_Abstract. I hope someone can help me ;) Greets apollox
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: Zend Decorator setOption() Error

weierophinney
Administrator
-- apollox <[hidden email]> wrote
(on Thursday, 22 March 2012, 08:12 AM -0700):

> i have at the moment a little problem in my project with the Zend Form
> Decorator. I want that the label elements of my forms have no  tag arround,
> because I want to display the complete form with other layout .
>
> My Code for that is the following:
> foreach ($form->getElements() as $element) {
> $element->getDecorator('label')->setOption('tag', null);
> }
>
> But then I got only the following error:
> Fatal error: Call to a member function setOption() on a non-object

Not all elements have labels in their default decorators -- for example,
button and submit elements. You should test the return of
getDecorator() before calling the setOption() method:

    foreach ($form->getElements() as $element) {
        $decorator = $element->getDecorator('label');
        if (!$dectorator) {
            continue;
        }
    $decorator->setOption('tag', null);
    }

--
Matthew Weier O'Phinney
Project Lead            | [hidden email]
Zend Framework          | http://framework.zend.com/
PGP key: http://framework.zend.com/zf-matthew-pgp-key.asc

--
List: [hidden email]
Info: http://framework.zend.com/archives
Unsubscribe: [hidden email]


Loading...