Is there a way we could integrate this to the framework ? I'm pretty sure everyone would benefit from a nice little patch that would add * to all required fields.
From: Luiz Vitor <prowler666@gmail.com>
To: fw-mvc@lists.zend.com
Sent: Monday, December 29, 2008 1:25:40 PM
Subject: Re: [fw-mvc] Adding * to label
Hi there
I managed to get this done subclassing Zend_Form and overriding the render() method:
public function render(Zend_View_Interface $view = null)
{
foreach ($this->getElements() as $element) {
$label = $element->getDecorator('Label');
if ($label instanceof Zend_Form_Decorator_Label) {
$label->setOption('requiredSuffix', ' <span>*</span>')
->setOption('escape', false);
}
}
return parent::render($view);
}
On Mon, Dec 29, 2008 at 9:11 AM, Zladivliba Voskuy <nospampam@hotmail.fr> wrote:
Hey, did you finally managed to find an answer to this problem ? It's an interesting question and I haven't found any answer to it..
--
My zend framework experience... the good, the bad
http://myzendframeworkexperience.blogspot.com/
> Hi,
>
> Currently I am using
>
> $element->getDecorator('label')->setOption('requiredSuffix', ' * ');
>
> to add * to required fields.
>
> I want to manage the markup from a centrally accessible place. Perhaps,
> a custom label decorator. If I wish to change the markup to
> <em>*</em> or to
> <div class="redAsterisk">*</div>
> it would be convenient to change it in one place.
>
> I just want to add this functionality to the label decorator and leave
> all else as is.
>
> What is the best method to accomplish this? I have seen some people
> adding * using CSS. I prefer to print the text character * and style it
> using CSS.
>
> It would be much more convenient if the custom decorator can check
> whether the element isRequired() and then add * to the label. But I
> can't figure out how to do it.
>
> Code examples would be highly appreciated.
>
> --
>
> With warm regards,
> Sudheer. S
> Business: http://binaryvibes.co.in, Tech stuff: http://techchorus.net, Personal: http://sudheer.net
>
>
Organisez une fête en un tour de main : invitation, photos, blog…
没有评论:
发表评论