LogoPhly, boy, phly
the weblog and site of Matthew Weier O'Phinney

Thursday, January 17. 2008

Zend_Form is ready for testing

I've spent the last couple months gathering requirements for the Zend_Form component, building a prototype, creating a composite proposal based on existing proposals and my research, gathering community feedback, and, finally coding the implementation. It's a testament to the value of Test Driven Development that I now have 302 unit tests passing covering the codebase... all in just over a week's time.

So, if you're interested in Zend_Form, now is the time to start testing it. You can grab it from subversion, where you'll find it in the incubator. You can find preliminary documentation on the Framework wiki.

Tags: zendframework, php, zend_form

Posted by Matthew Weier O'Phinney at 15:26 | Comments (13) | Trackbacks (0)

Trackbacks
Trackback specific URI for this entry

No Trackbacks

Comments
Display comments as (Linear | Threaded)

Hello. I think it's a great component and now I'm testing it on my test site. It is very flexible and allows personalizations.

The only thing I can't do to work is the DisplayGroup. Maybe it's because I'm not an experienced programmer ;-)
#1 Karen Nalbandian on 2008-01-18 17:54 (Reply)
I haven't yet gotten to the DisplayGroup documentation; hopefully once I have, the feature will make more sense. :-)
#1.1 Matthew Weier O'Phinney (Link) on 2008-01-18 22:35 (Reply)
Hello, Matthew! Sorry for my english ;-)

I try to play with ZF-1.5.0PR and Zend_Form. I founded that Zend_Form_Element::getAttribs() method don't return valid attributes. Example:
Zend_Loader::loadClass('Zend_Form');
$form = new Zend_Form(array(
'action' => $this->getRequest()->getBaseUrl(),
'method' => 'post',
'elements' => array(
'test' => array(
'text', array('size' => '50'),
),
'submit' => array(
'submit', array('value' => 'tfdsf'),
),
)
));
$form->getElement('test')->setAttrib('ff', '11');
Zend_Debug::dump($form->getElement('test')->getAttribs());
#2 Hinikato (Link) on 2008-01-29 22:31 (Reply)
Hinikato, this is a known issue in PHP 5.1.x, and there is an issue for it in the Zend Framework bug tracker. I'll be attempting to fix it this week.
#2.1 Matthew Weier O'Phinney (Link) on 2008-01-30 08:02 (Reply)
$form->getElement('test')->setAttrib('ff', '11');
Zend_Debug::dump($form->getElement('test')->getAttribs());
this lines i add after Zend_Debug::dump($form->getElement('test')->getAttribs()) return empty array for size attribute.
#3 Hinikato (Link) on 2008-01-29 22:34 (Reply)
I write simple bug fix:
public function getAttribs()
{
$attribs = array();
foreach (get_object_vars($this) as $property => $value) {
if ($property[0] == '_') {
continue;
}
$attribs[$property] = $value;
}
return $attribs;
}
Is it bug?
#4 Hinikato (Link) on 2008-01-29 22:44 (Reply)
Hi,

In the render method in the Zend_Form class (lines 1672-1684, incubator rev. 7704), I believe line 1681 (concatenation of content within foreach) should be:

$content .= $decorator->render($content);

instead of:

$content = $decorator->render($content);

Haven't tested it though...
#5 Arjan on 2008-01-30 16:12 (Reply)
Arjan, i think this is not the bug. Because decorators change content and return it. You may not has decorators and in that case content will ''.
#5.1 Hinikato (Link) on 2008-01-30 18:45 (Reply)
Hinikato is correct -- decorators modify content, and thus render() does not concatenate. Decorators may choose to append, prepend, or replace the content internally (and often this is configurable by specifying a 'placement' option to the decorator).
#5.2 Matthew Weier O'Phinney (Link) on 2008-01-31 06:37 (Reply)
Matthew, i try to change default elements decorators but this was inconvenient... Zend_Form and Zend_Form_Elements constructors define default decorators and i can't redefine them. I found only one method Zend_Form::setElementDecorators but if i try use it, i can't find method to get $_defaultHelper Zend_Form_Elements property.
Example:
$decorators = array(
array('ViewHelper', array('helper' => ???)), // i can't get $_defaultHelper property
array('Label', array('tag' => 'dt')),
array('HtmlTag', array('tag' => 'dd')),
array('Errors'),
);
$form->setElementDecorators($decorators);
May be best way is take user decorators as constructor parameter and merge them with default decorators (in Zend_Form and Zend_Form_Element to).
#6 Hinikato (Link) on 2008-01-31 23:34 (Reply)
...and this should increase productivity (very little), because I should not remove decorators that I do not want (which defined in constructors and are default).
#6.1 Hinikato (Link) on 2008-01-31 23:41 (Reply)
Hinikato -- you raise some good points, and I'll see if I can address them. Regarding the $_defaultHelper property, if you're using the standard elements, this is a non-issue, as the ViewHelper decorator can also determine the correct view helper based on the element's class name.

BTW, you may want to join the fw-mvc@lists.zend.com mailing list, which I monitor; you can then benefit from the much larger discussion of Zend_Form that has been occurring there.
#6.2 Matthew Weier O'Phinney (Link) on 2008-02-01 08:06 (Reply)
Matthew, thank you ;-)
#7 Hinikato (Link) on 2008-02-02 00:21 (Reply)

Add Comment

Standard emoticons like :-) and ;-) are converted to images.
E-Mail addresses will not be displayed and will only be used for E-Mail notifications

To prevent automated Bots from commentspamming, please enter the string you see in the image below in the appropriate input box. Your comment will only be submitted if the strings match. Please ensure that your browser supports and accepts cookies, or your comment cannot be verified correctly.
CAPTCHA

 
 
  • Home
  • Resume
  • Blog
  • Phly PEAR Channel
  • Contact Me
  • About this site

ZCE

Zend Education Advisory Board Member

Add to Technorati Favorites

Calendar

Back October '08
Mon Tue Wed Thu Fri Sat Sun
    1 2 3 4 5
6 7 8 9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28 29 30 31    

Quicksearch

Links

  • PHLY - PHp LibrarY
  • Paul M. Jones
  • Mike Naberezny
  • Shahar Evron
  • Planet PHP
  • Zend Where I now work
  • Garden.org Where I once worked

Archives

October 2008
September 2008
August 2008
Recent...
Older...

Categories

XML Linux
XML Personal
XML Aikido
XML Family
XML Programming
XML Dojo
XML Perl
XML PHP

All categories

Syndicate This Blog

XML RSS 0.91 feed
XML RSS 1.0 feed
XML RSS 2.0 feed
ATOM/XML ATOM 0.3 feed
ATOM/XML ATOM 1.0 feed
XML RSS 2.0 Comments

Show tagged entries

xml best practices
xml books
xml conferences
xml dojo
xml dpc08
xml file_fortune
xml linux
xml mvc
xml oop
xml pear
xml personal
xml php
xml phpworks08
xml programming
xml ubuntu
xml webinar
xml zendcon
xml zendcon08
xml zend framework
© 2004 - present, Matthew Weier O'Phinney
matthew-web <at> weierophinney.net