1

Topic: ZC49 – Writing Composite Zend_Form Elements

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.

2

Re: ZC49 – Writing Composite Zend_Form Elements

Hi:
here is my code and how i made a composite form element for the Date Of Birth

http://pastie.org/915510

the code my not be as good as you might think , but we are all learning something new everyday big_smile

thanks

Best Regards , Mhd Zaher Ghaibeh
Creative Web Group
http://www.creativewebgroup-sy.com
http://www.msrofi.com

3

Re: ZC49 – Writing Composite Zend_Form Elements

Hi Zeherg,

thanks for mentioning this!

4

Re: ZC49 – Writing Composite Zend_Form Elements

your most welcome ..
i hope that you can make a cast about how to create a composite form element other than text since its ( text elements ) already mentioned in other places.

Best Regards , Mhd Zaher Ghaibeh
Creative Web Group
http://www.creativewebgroup-sy.com
http://www.msrofi.com

5

Re: ZC49 – Writing Composite Zend_Form Elements

hi :
i just want to put a note that you have not to use

$this->html

in your code instead you will have to use the

$html 

.
other wise if you have 2 elements it will be rendered as 3 elements since that

$this->html

will not be reset for the next element ..

check my code since i have just made the changes ..
http://pastie.org/915510

regards

Best Regards , Mhd Zaher Ghaibeh
Creative Web Group
http://www.creativewebgroup-sy.com
http://www.msrofi.com

6

Re: ZC49 – Writing Composite Zend_Form Elements

Hi Jon,

it looks like, the helper is only instantiated once. So if you use $this->html, to store the generated html-code, and append new html-code, every time a new element is added to the form, the new html-code will be appended to the previous. That is, what zaherg worte a few days before.

And btw: thank you, Jon, for your great zend tutorials!

Oliver

7

Re: ZC49 – Writing Composite Zend_Form Elements

Hi Oliver, very good point! I missed that when I put together that helper.