Zend Framework: Setting decorators and labels - should this be done in the view or the form class?

I typically declare my decorators and such in a class in a custom library for the project or in a view helper that I can then call in on each form and still have all the decorators in one location to reduce the amount of code needed for them.

I think the major reason why "anyone else isn't working with their forms like this" is because, for the most part, a site will only use one or two 'default' decorators. If you are going to decorate the inputs the same way 90% (perhaps less) of the time, why bother declaring it in every view script? Like gokujou's answer, I too will create a custom decorator class in my library.

See Creating Custom Form Markup Using Zend_Form_Decorator I do like your approach, but I think it's most appropriate for instances where you have a deviation from the standard decorator(s). If I'm using the same decorators the majority of time, I don't want to have to bother with declaring it in my view script.

I think we're on the same page. I wasn't clear, but my question is about the exceptions to the default decorators. Like you, I will define my default decorators in a central spot.

Currently I'm doing this in a base form class, because there is a loadDefaultDecorators() method you can override. I would prefer if there was a way to set the default decorators in a layout script however. – asgeo1 Nov 16 '10 at 2:19 @asgeo1, "I would prefer if there was a way to set the defaults up in a layout script instead however." - Certainly your example works?

The question wasn't "Why isn't this possible? " it was "Why isn't everyone else doing this?" – Fatmuemoo Nov 16 '10 at 2:26 Sorry, I'm confusing you more. When I say I would prefer if there was a way to set the defaults up in a layout script instead however - I'm just complaining about the default decorators in general.

My actual question is about the non-default decorators. I'm genuinely confused why most people would create them in a Form class as opposed to a view script. – asgeo1 Nov 16 '10 at 2:50.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions