formLabel and escaping

View: New views
5 Messages — Rating Filter:   Alert me  

formLabel and escaping

by Teemu Välimäki :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

In Zend_Form I'd like to have label linked, but formLabel escapes output. I
was wondering if it would be smart to add $escape = true parameter to
formLabel to control escaping? The problem what I have is currently with
Zend_Form so I could create a workaround, but it could pop up later on when
using View Helpers.

--
Teemu Valimaki <teemu.valimaki@...>

Re: formLabel and escaping

by Matthew Weier O'Phinney-3 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

-- Teemu Välimäki <teemu.valimaki@...> wrote
(on Tuesday, 04 March 2008, 03:29 PM +0200):
> In Zend_Form I'd like to have label linked, but formLabel escapes output. I
> was wondering if it would be smart to add $escape = true parameter to
> formLabel to control escaping? The problem what I have is currently with
> Zend_Form so I could create a workaround, but it could pop up later on when
> using View Helpers.

Actually, you already can do this ;-)

Grab your label decorator:

    $label = $element->getDecorator('label');

And set the escape option to false (so you can render HTML in the
label):

    $label->setOption('escape', false);

Alternately, you can do this at decorator creation time by passing the
escape option:

    $element->addDecorator('label', array('escape' => false));

When $escape is true (the default), the label will be escaped using the
view object's escaping mechanism. When false, no escaping will be done.

The escape flag is already built into the view helpers, and can be
passed into the $attribs array each form view helper accepts (though not
all of them honor it at this point).

--
Matthew Weier O'Phinney
PHP Developer            | matthew@...
Zend - The PHP Company   | http://www.zend.com/

Re: formLabel and escaping

by Martin Hujer :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi, I've already reported this as ZF-2473. As long as I know, Zend_Form uses this helpers, so it should be OK. Regards Martin H.
Teemu Valimaki wrote:
In Zend_Form I'd like to have label linked, but formLabel escapes output. I was wondering if it would be smart to add $escape = true parameter to formLabel to control escaping? The problem what I have is currently with Zend_Form so I could create a workaround, but it could pop up later on when using View Helpers. -- Teemu Valimaki

Re: formLabel and escaping

by Joshua Ross :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Matthew Weier O'Phinney wrote:

> -- Teemu Välimäki <teemu.valimaki@...> wrote
> (on Tuesday, 04 March 2008, 03:29 PM +0200):
>> In Zend_Form I'd like to have label linked, but formLabel escapes output. I
>> was wondering if it would be smart to add $escape = true parameter to
>> formLabel to control escaping? The problem what I have is currently with
>> Zend_Form so I could create a workaround, but it could pop up later on when
>> using View Helpers.
>
> Actually, you already can do this ;-)
>
> Grab your label decorator:
>
>     $label = $element->getDecorator('label');
>
> And set the escape option to false (so you can render HTML in the
> label):
>
>     $label->setOption('escape', false);
>
> Alternately, you can do this at decorator creation time by passing the
> escape option:
>
>     $element->addDecorator('label', array('escape' => false));
>
> When $escape is true (the default), the label will be escaped using the
> view object's escaping mechanism. When false, no escaping will be done.
>
> The escape flag is already built into the view helpers, and can be
> passed into the $attribs array each form view helper accepts (though not
> all of them honor it at this point).
>


Any way to do this through a Zend_Config ini file?

-Joshua-


Re: Re: formLabel and escaping

by Matthew Weier O'Phinney-3 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

-- Joshua Ross <joshualross@...> wrote
(on Thursday, 08 May 2008, 03:36 PM -0700):

> Matthew Weier O'Phinney wrote:
> > -- Teemu Välimäki <teemu.valimaki@...> wrote
> > (on Tuesday, 04 March 2008, 03:29 PM +0200):
> > > In Zend_Form I'd like to have label linked, but formLabel escapes
> > > output. I was wondering if it would be smart to add $escape = true
> > > parameter to formLabel to control escaping? The problem what I have
> > > is currently with Zend_Form so I could create a workaround, but it
> > > could pop up later on when using View Helpers.
> >
> > Actually, you already can do this ;-)
> >
> > Grab your label decorator:
> >
> >     $label = $element->getDecorator('label');
> >
> > And set the escape option to false (so you can render HTML in the
> > label):
> >
> >     $label->setOption('escape', false);
> >
> > Alternately, you can do this at decorator creation time by passing the
> > escape option:
> >
> >     $element->addDecorator('label', array('escape' => false));
> >
> > When $escape is true (the default), the label will be escaped using the
> > view object's escaping mechanism. When false, no escaping will be done.
> >
> > The escape flag is already built into the view helpers, and can be
> > passed into the $attribs array each form view helper accepts (though not
> > all of them honor it at this point).
>
> Any way to do this through a Zend_Config ini file?

Yes -- pass it in the options array for the decorator:

    element.options.decorators.label.decorator = "Label"
    element.options.decorators.label.options.escape = 0

--
Matthew Weier O'Phinney
Software Architect       | matthew@...
Zend - The PHP Company   | http://www.zend.com/