views:

68

answers:

2

I would like to edit an element description in the action controller. I'm trying to do it like this:

$form->element->setAttrib('description', '');

But it doesn't work. Any ideas?

+2  A: 

You have to define your own form element decorators, omitting the description decorator. Check this tutorial for details.

Ivan Krechetov
Thanks. I know about decorators. What I needed to do is to have the decorators include the description attribute but remove the description in controller based on data from the request object. I have figured out how to do it already (I used $form->element->removeDecorator('description'); in the action controller).
Richard Knop
+1  A: 

To actually remove the description data, rather than the description decorator, you can use:

$form->getElement('elementName')->setDescription('');
berty
Well, that's what I did (see my OP - it's just an alternative using magic __get()) and it didn't work. I had to remove the decorator to get rid of the description.
Richard Knop
Oh. Well, I have no good answer for that I'm afraid, other than it works for me (ZF 1.9).
berty