I haven't tried a foreach loop, but I have had success in removing the dt
tags from MOST of the form elements... well, everything other than Submit,
by using:

->removeDecorator('htmlTag');

or

->removeDecorator('DtDWrapper');

Of course, I simply use these on the form elements, like so:

        $pswd = new Zend_Form_Element_Password('pswd');
        $pswd->setAttrib('size', 35)
             ->removeDecorator('htmlTag');

        $submit = new Zend_Form_Element_Submit('submit');
        $submit->setLabel('Login')
               ->removeDecorator('DtDWrapper');

Since you're using a foreach loop - have you tried getElement() instead of
getElements() ?

Just curious. I'm interested in seeing a solution for this, too.

On Thu, Jan 19, 2012 at 4:55 PM, Rob Haag <[email protected]> wrote:

> Hi,
>
> I am attempting to get my forms to have no html tags, I have attempted in
> several ways, some came from here... http://mwop.net/blog/215-Rendering-
> Zend_Form-decorators-individually (O'Phinney's site),
> from that site I attempted the 'foreach' loop in my view script like so...
>
> foreach ($form->getElements() as $element) {
>                           $element->getDecorator('label')->setTag(null);
>                        }
>
> resulting in a "Call to a member function setTag() on a non-object" error,
> as the same happens if I do this...
>
>        $this->removeDecorator('HtmlTag');
>        foreach ($this->getElements() as $element) {
>            $element->addDecorator('Label');
>            $element->getDecorator('Label')->setTag(null);
>            $element->removeDecorator('HtmlTag');
>            $element->removeDecorator('DtDdWrapper');
>
>        }
>
> after all of my 'addElement' code in my form class (extends Zend_Form).
>
> If I put the above code at the top of my init() function, it does nothing
> at all...my labels still have the '<dt>' tags rendering like so...
>
>  <dt id="date-label"><label for="date" class="optional">Date
> (DD/MM/YYYY):</label></dt>
>
> I am trying to have no tags at all so I can call each element individually
> in my veiw script and manipulate the form to my requirements, plus adding
> <hr /> tags, etc.
>
> Is there still a bug with setTag() ? do I have to add a decorator first,
> then remove it? I'm a bit baffled on this one...
>
> Thanks
>



-- 
Thanks,

Clint Lenard

www.ClintLenard.com
www.Affiliit.com

*"Great minds discuss ideas*, *average minds discuss events*, *small minds
discuss people*." - Eleanor Roosevelt

*"**I've learned that mistakes can often be as good a teacher as success.*"
- Jack Welch

Reply via email to