Writing Composite Zend_Form Elements

March 10th, 2010

This video should help you build your own composite Zend_Form element. We’ll be building a phone element. The phone element will have 3 textboxes, one for geographic location, area code and local code. In the following videos will add a custom cell phone validator and some ajax validation.

Grab a copy of the project or browse the repository.

ServerGrove has offered to sponsor 3 videos in March! 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”.
 


discuss video in the forum

8 Responses to “Writing Composite Zend_Form Elements”

  1. umpirsky says:

    Didnćt watch the screen, but according to google code I think http://code.google.com/p/zendcasts/source/browse/trunk/zc49-composite-form-elements/library/ZC/Form/Element/Phone.php need getValue)= method override.

  2. jon says:

    Zend_Form_Element_Xhtml extends from Zend_Form_Element, which implements Zend_Validate_Interface as well as the getValue() method. In the next video, I’ll be writing our own method override and using a string delimiter rather than an array.

  3. Kevin says:

    I’m looking forward to the next installment, I’ve seen other composite elements that use a decorator to render, I’m curious which method is better (view vs. decorator).

  4. [...] recent tutorial (screencast) has been posted to the ZendCasts.com site looking at creating custom Zend_Form elements when you need something more than just the usual, simple elements. This video should help you [...]

  5. Alex says:

    Thanks for the tutorial, helped me to clarify several aspects while coding an autocomplete custom form element for an application. One remark though: in the composite element’s view helper, the protected “$html” variable must be reset to an empty string inside the helper’s method, because if you want to use more than one “phone” element in the same form, the new $html content will be appended to the old one with each new element – I suppose the helper class is instantiated once and re-used after when necessary (this make the $html persistent and thus must be reset). Anyway great video, thanks a lot!

  6. hello everyone , i hope you can read this before you work with the code ..
    http://www.zendcasts.com/forum/post/790/#p790

Leave a Reply

Desktop RSS feed iPhone + iPod