On Mon, 15 Dec 2008, Kevin Waterson wrote: > My proposal is for an ezcForm component. > The ezcForm component would provide an interface to the creation > of HTML form objects which may be rendered for use with templates. > > Each form element would be an object which whose properties would > define how the form would be rendered. > eg: > > <?php > $form = new ezcForm; > > $form->setMethod('post'); > $form->setId('my_form_id'); > $form->setAction($url);
Usually, we would just use properties for this, and not setter methods. > > $select = new ezcFormSelect; > $select->options($array) > ->setLabel('My Select') > ->setId('my_select_id'); > > $submit = new ezcFormSubmit; > $submit->setValue('Click Me') > ->setScript('onclick="do_some_js"'); > > $form->render(array($select, $submit)); > ?> > > Also proposed, is the ability to attach validators directly to > to each object. > > <?php > $txt = new ezcFormText; > $text->setName="email") > ->setId("email") > ->setLabel('Enter Email') > ->setRequired(true) > ->setValidator(ezcFormValidateEmail); > ?> > > In this instance, ezcFormValidateEmail could be a call back to > new ezcInputFormDefinitionElement( > ezcInputFormDefinitionElement::REQUIRED, 'validate_email' > ) > > > An ezcForm component will provide a comprehensive suite of > easy to use form objects with an easy to use API. Forms will > initially be defined insite a definition list, but other > markup should not be hard to build in. > > Larson was working on something similar at some time in > experimental, but after a quick chat on IRC he described his > as overly complex. I'd be nice to have some frontend/backend interaction going on here where you have both client- and server-side validation. The widget thing that Larson had was a bit complex, but it does provide some good ideas as well. regards, Derick -- Components mailing list Components@lists.ez.no http://lists.ez.no/mailman/listinfo/components