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

Thursday, July 28. 2005

Form madness

Those who follow my blog may remember an earlier entry on form validation. I looked into some of the possible solutions those who commented provided, but other than Solar_Form, each was either trying to generate HTML, or not generating HTML was considered a plugin type of behaviour (i.e., the HTML generation was the norm, and not generating HTML typically added layers). Discouraged, I continued plugging away on my own solution which was incorporating Solar_Valid for validations, adding some filtering, adding the ability to load definitions from a file, and adding the ability to use callbacks for either filters or validation rules.

I got some code together, tried it out, and felt that either something was missing, or I was doing something a little wrong. I posted the code source, and asked Paul Jones for feedback.

After some initial flurries of emails with Paul asking for more detail, me providing it, Paul asking questions, me attempting to answer... Paul had me look at the source for Solar_Form. In doing so, I discovered what he was suspecting, namely, that we were trying to build something similar. Rather than continue on parallel courses, I decided to jump in and help in this aspect of the Solar project.

And thus was Solar_Filter born, and then Solar_Form_Load_Xml. Solar_Filter is a class of static methods that provide ways to filter data; its primary use would be for pre-filtering form data before validation. In most cases, you may simply register a PHP function that accepts a value as an argument and returns a value; otherwise, all filter methods expect the value to filter as the first argument, and any other arguments follow. Solar_Form_Load_Xml loads a Solar_Form definition from an XML file using PHP5's simplexml functions. It simply takes the XML and creates an array that is compatible with Solar_Form::setElements().

I've also helped with a number of changes to Solar_Form -- you can now pass arrays to validate() instead of using the $_POST and/or $_GET arrays (useful for validating subsets or data coming from XMLHTTP requests), elements can have pre-filters via Solar_Filter, and you can load() form element definitions (currently via Solar_Form_Load_Xml only).

You may view Paul's and my handiwork by checking out Solar via the Solar subversion repository; the affected modules are Solar_Form, Solar_Filter, and Solar_Form_Load_Xml.

Documentation will be forthcoming once we iron out some bugs and get some good unit tests going. In the meantime, the API documentation is fairly coherent and informative. Questions may be directed to the Solar mailing list .

If you can, start testing so we can incorporate feedback for Paul's next release of Solar!

Posted by Matthew Weier O'Phinney in PHP at 00:08 | Comments (0) | Trackback (1)

Trackbacks
Trackback specific URI for this entry

PHP Input Validation talk
On Saturday I gave a talk about form processing and input validation to the Twin Cities PHP User Group .
Weblog: afongen
Tracked: Aug 23, 23:06

Comments
Display comments as (Linear | Threaded)

No comments

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
  • Twitter
  • Contact Me
  • About this site

ZCE

Zend Education Advisory Board Member

Add to Technorati Favorites

Calendar

Back September '10
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      

Quicksearch

Links

  • PHLY - PHp LibrarY
  • Planet PHP
  • Zend Framework, where I'm project lead
  • Sebastian Bergmann
  • Cal Evans
  • Shahar Evron
  • Paul M. Jones
  • Bill Karwin
  • Mike Naberezny
  • Fabien Potencier
  • Ben Ramsey
  • Derick Rethans
  • Ralph Schindler
  • Marco Tabini

Archives

September 2010
August 2010
July 2010
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 apache
xml best practices
xml books
xml conferences
xml cw09
xml decorators
xml dojo
xml dpc08
xml file_fortune
xml git
xml linux
xml mvc
xml oop
xml pear
xml perl
xml personal
xml php
xml phpworks08
xml programming
xml rest
xml ubuntu
xml vim
xml webinar
xml zendcon
xml zendcon08
xml zendcon09
xml zend framework
© 2004 - present, Matthew Weier O'Phinney
matthew-web <at> weierophinney.net