This little video tutorial should set you up for building your own custom Zend_Form decorators in 15 minutes. I’ll show you how you can make the necessary class and have it easily added to your existing Zend_Form_Decorator configuration.
Grab a copy of the project or browse the repository.
In other news, ServerGrove is giving Zendcast viewers a coupon! ServerGrove specializes in Zend Framework hosting and they’ve offered a 10% rebate on hosting with coupon code “zc”. If you’re looking for a host, be sure to check them out (referral). They’ve also added an additional coupon for “Mini Hosting” plans, get $2 off by using code “zcmini”.

Exactly what I needed! Thanks a lot!
Sweet talk, this one and the previous on decorators have been insanely useful.
One suggestion that would seem appropriate for the decorator you made in this talk, is to use:
$Form->setDescription($text);
and then $Form->getDescription();
Obviously we could set that as the text option when we add our decorator, however are there any options for a more automatic approach such as getting the form from within the decorator? At first glances it doesn’t seem like that’s possible.
Again great talk, really helpful.
Great! I was just digging in to this thing.
hey Benjamin,
you’re absolutely correct about setDescription being an option, however simply using the method available wouldn’t have helped illustrate how the decorators are constructed.
I was looking for video like this one for a while. Thanks
By the way, I had to spend some time last year in order to find out how could prefix paths be set from ini config file. Here’s what worked for me:
post.edit.elementPrefixPath.validate._Validate.path = “/Validate”
post.edit.elementPrefixPath.validate._Validate.prefix = “_Validate”
// ‘post’ usually being a controller name
// ‘edit’ usually being an action name
Yes!
With such examples it makes more easier and comfortable to work with Zend Framework!
I opend my eyes to make my code better in no time! Thank’s!
The only thing I don’t like about decorators for something like that is that when the text needs to be changed, I (the programmer) have to be bugged to change it. Note, I do like decorators for their re-usability, but lately I’ve just been dumping all the individual form elements out to the page (as you mentioned in the beginning) so that I never have to worry about changing little things like text, e.g.
Give us your name
form->getFirstName(‘First Name:’)?>
@strick: I definitely agree with you, however there are other implications to this. Obviously passing strings is a very simple example, however nothing is stopping you from building a view helper/script and loading it via the decorator. Being able to pass parameters from the form into the decorator also lets you easily adjust the forms’ markup via your own custom implementation. Passing text is only the tip of the iceberg!
setting prefix paths from config file
// using an INI config file:
form.elementPrefixPath.zc.prefix = Zc_Form_Decorator”
form.elementPrefixPath.zc.path = “Zc/Form/Decorator”
form.elementPrefixPath.zc.type = “decorator”
// Or using an XML config file:
Zc_Form_Decorator
Zc/Form/Decorator
decorator
sorry
<form>
<elementPrefixPath>
<my>
<prefix>My_Form_Decorator</prefix>
<path>My/Form/Decorator</path>
<type>decorator</type>
</my>
</elementPrefixPath>
</form>
Thanks Ishi! I’ll try it out this week
How would I set the html to be a ul/li set up through the decorator class?
Render doesnt seem to have access.
Very good Tutorial. Hope you create some more ! Thanks a lot!
Great presentation!
Heya¡my very first comment on your site. ,I have been reading your blog for a while and thought I would completely pop in and drop a friendly note. . It is great stuff indeed. I also wanted to ask..is there a way to subscribe to your site via email?
This is an excellent video! I like it very, very much! It has helped me a lot and improved my understanding. I cannot say enough thanks at all
hey jon
i get this error when trying to run
Fatal error: Class ‘Form_Login’ not found in \application\controllers\IndexController.php on line 21
(yes i replaced registratoin with login)
do you have any ideas?
i was thikning that since the forms dir is new
maybe it doesnt know to include the file inside there
(for me its “Login” as aopposed to your “Registraitron”
thanks!
@toy:
in your application.ini, do you have the appnamespace directive set to “” ?
e.g. appnamespace = “”
Thanks a bunch for this cast. Helped me a lot to understand possibility to overwritte zend decorators.
Good job!
Thanks a lot. Good video.
Thanks a lot, this video is a excellent tutorial. Just started with Zend and the tutorials / documentation are usually confusing, this was perfect though. Keep up the good work
Great tutorial! It saved my life. Thank’s a lot and keep on going with your great work.
That was very descriptive article…
You’re truly right on this piece!
How can you add decorator to a specific Elements in the form? Say you don’t want to have the decorator around all the elements but a specific element. How can this be achieved?
Don’t bother approving my previous comment…
Figured it out.