Form handling

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



I've been charged with writing a class that handles forms, once they've been
POSTed to.  The idea of the class is to handle the most common use-cases of
POST forms, and any special functionality can be handled with a child class
at a later date, but for our uses, we're going to have mostly pretty typical
POST forms.  Follows is the list of cases I've determined that are the most
common, can anyone think of any that are omitted or that are never going to
be used?

class form_handler {
    public /* bool */ function setRequiredFields(array $fields); //takes a
simple array that corresponds to a $_POST key, verifying that there is data
on required fields but not for optional fields, returns true or false on
error
    public /* bool */ function setRequiredFieldTypes(array $fieldTypes);
//array of field names => type a la ('username' => array(regex,
'/a-zA-Z0-9\-_/'))
                //or 'phone_number' => (array('int', 'min_len' => 7,
'max_len' => 10)) etc, the exact spec is obviously nowhere near done but
will probably just wrap a lot of filter_ functions, returns true or false on
error
    public /* string */ function validateAndCaptureError(); //returns error
or empty string
    public /* void */ function validateAndForwardTo($page); //forwards to
page on error, or not
}

each of the globule setters will have a corresponding appendRequired...
method, so as not to require handling enormous data structures for
conditional form building.
♦
As you can see, the class looks pretty barren, but I can't think of any more
functionality than would be required, although I am kickign the idea around
of having very specific validation type methods ie.
form_handler::requireInt($field, array $options) or
form_handler::requireRegex($field, $regex), etc.

Thoughts?

Thanks in advance,
--Eddie

[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux