In the previous installment of this series on
Zend_Form decorators, I looked at how you can combine
decorators to create complex output. In that write-up, I noted that while
you have a ton of flexibility with this approach, it also adds some
complexity and overhead. In this article, I will show you how to render
decorators individually in order to create custom markup for your form
and/or individual elements.
By the time you read this, the Zend Framework team will have released a preview release of 1.8.0. While the final release is scheduled for later this month, this release represents the hard work of many contributors and shows off a variety of powerful new components.
If you're a Zend Framework user, you should give the preview release a spin, to see what it can do:
This marks the second in an on-going series on
You may have noticed in the previous installment
that the decorator's
render() method takes a single argument,
$content. This is expected to be a string.
render() will then take this string and decide to either
replace it, append to it, or prepend it. This allows you to have a chain of
decorators -- which allows you to create decorators that render only a
subset of the element's metadata, and then layer these decorators to build
the full markup for the element.
Let's look at how this works in practice.
I've been seeing ranting and general confusion about Zend_Form decorators (as well as the occasional praises), and thought I'd do a mini-series of blog posts showing how they work.
I'm an unabashed Vim user. It has been my primary editor for over seven years now, when I switched to it to make it easier to edit files over SSH. At the time, I made myself use it exclusively for a month so that the habits would be ingrained, and took the time to go through vimtutor as well as to order and read Steve Oualline's Vim book. And when I say "exclusively," I mean it -- I switched to using Mutt for email at that time, and also started doing all code development, outlining, and more in vim. And after a month, I realized I didn't want to use anything else.
Ironically, I find myself working for a company that sells an Integrated Development Environment (IDE). As a result, I've done some test runs with Eclipse, Zend Studio for Eclipse, and even NetBeans, to see what features they offer and to see if there would be anything compelling that might make me change my mind.
Being a technical presenter, I've often run up against the issue of how to present code snippets.
The easiest route is to simply cut-and-paste into your presentation software. However, such code is basically unreadable: it's hard to get indentation correct, and the lack of syntax highlighting makes them difficult to read (syntax highlighting helps users understand the purpose of the various language constructs).
I'm speaking at PHP Quebec this week. While I live a scant 1.5 hours away from the venue, this is the first I've been to the conference. The snow gods have declared their wrath already, but I plan to thwart them and drive up to Montreal this evening regardless.
I'm giving two talks and participating in a panel discussion this week. The first talk is entitled "Practical Zend Framework Jutsu with Dojo," and, while it may look like a familiar topic of mine by this point, I've spent the last several days reworking the talk entirely, and am very much looking forward to presenting it tomorrow. (My copy of "Presentation Zen" could not have come soon enough! and that's all I'll say about that.)
On Friday, PHP Quebec has introduced a "Framework Bootcamp" track, including sessions by myself, Fabien Potencier of symfony, and Derick Rethans representing eZ Components. My talk that day is entitled "Zend Framework Little Known Gems." While hardly a completely original talk (Aaron Wormus did a "Hidden Gems" series of posts for DevZone a couple years back, and Zend's own Shahar Evron did a similar talk at last fall's IPC), this will be my first time doing a Zend Framework talk on something other than the MVC stack (or how to use components with the MVC stack). Leaving my comfort zone, so to speak.
Towards the end of the day, Fabien, Derick, and myself will be corralled onstage together for a "Framework Comparison".
If you're headed up to PHP Quebec this week, I look forward to meeting you or seeing you again!
I ran into an issue recently with Dojo's ContentPanes. I was using them with a TabContainer, and had made them closable; however, user actions might re-open tabs that pull from the same source. This led to conflicts with dijit IDs that I had to resolve.
Most Dijits have a
destroyRecursive() method which should,
theoretically, destroy any dijits contained within them. However, for many
Dijits, this functionality simply does not work due to how they are
implemented; many do not actually have any knowledge of the dijits beneath
ContentPanes fall into this latter category. fortunately, it's relatively easy to accomplish, due to Dojo's heavily object oriented nature.
I've been doing a fair bit of programming in Dojo lately, and have on occasion run into either inconsistent interfaces, or interfaces that simply fail to load in Internet Explorer. Several people have pointed out to me some optimizations to make, but, being a lazy programmer, I often forget to do so.
Yesterday, we released Zend Framework 1.7.5. It contains a somewhat controversial security fix to Zend_View that could potentially affect some use cases of the component; I'm providing details on that security fix as well as how to work around it here.