Hi, the rating of the UserInput component vary between "not as good as it could be" and "stinky crap". Since I need to handle a rather complicate form now, I start implementing an "HtmlForm" component on my own. It's aim is to solve my problem at hand in a matter of hours, but I'd be happy, if it could become the prototype of a new form handling component in ezc.
My (incomplete) notes so far: Other PHP Projects with Form handling components ================================================ Interesting ----------- - Agavi: AgaviValidator http://www.agavi.org/ interesting - Codeigniter http://codeigniter.com/user_guide/libraries/form_validation.html - Symfony http://www.symfony-project.org/forms/1_2/en/ Not so interesting ------------------ - http://phpfuse.net/wiki/index.php?title=API:FuseFormValidator Crap ---- - ZF. - CakePHP: One class FormHelper - kohanaphp http://dev.kohanaphp.com/projects/formo/repository/browse/trunk/libraries CRAP Requirements ============ - Testable with PHPUnit - Validation can depend on multiple elements - Custom Validators can be added - Form objects can be used - inside a template to mark erroneous fields - in a system like eZ Publish, where a form is build from many datatypes - in the controller to get quick access to validated user input - Element Groups can be reused in different forms - The component doesn't help in building the form. - Forms can be represented as PHP classes: $regForm = new myAppRegistrationForm - A form consists of a root Element Group which contains Elements or other Element Groups. The resulting Graph can be visited - All Classes can be replaced by other implementations, since checks are done against interfaces. Design ====== Interfaces ---------- inputsource ^^^^^^^^^^^ abstracts access to POST/GET to ease Unit Testing hasData getFilteredInput( $elementName, $filterId, array( 'options' => $inputElement- >options, 'flags' => $flags ) ) form ^^^^ ButtonElement getButton() setButton( ButtonElement ) ElementGroup elements parsable ^^^^^^^^ parse( $form, $inputSource ) parses input and sets values / error information isValid interface ElementGroup ^^^^^^^^^^^^^^^^^^^^^^ implements parsable implements visitable getElements addElement getElementByName interface Element ^^^^^^^^^^^^^^^^^ implements parsable implements visitable properties requiredPresent requiredNonEmpty value htmlName htmlType validator interface Validator ^^^^^^^^^^^^^^^^^^^ The validator is optional or can be a proxy validator to group several validators. First validation is done by the filter extension. Thomas Koch, http://www.koch.ro -- Components mailing list Components@lists.ez.no http://lists.ez.no/mailman/listinfo/components