[Catalyst] Design of a new form validator

John Siracusa siracusa at mindspring.com
Thu Dec 1 14:18:44 CET 2005

On 12/1/05 1:35 AM, Bill Moseley wrote:
> One thing I think would be useful is to define reusable fieldsets that
> could be put together to make a form.  An example might be an address
> that is made up of multiple fields.  Often you might have multiple
> forms that include a place to enter an address.  So it would be nice
> to define an object that represents an address and can be used on
> multiple forms.  Rose-HTML-Objects can build multiple element fields,
> but I'm not sure if you can defined "formlets" and connect them
> together into a larger form.

You can just define an actual form for each fieldset, then aggregate all the
sub-forms in a single master form.  You'd extract each sub-form's fields in
the master form's build_form() method, and you'd call each sub-form's
validate() method from the master form's validate() method.

Or, of course, you can also make a single compound "address" field have have
it return an Address object.  But then you'd need an address() attribute on
your db object (or whatever) that knows how to pull the individual pieces of
information out of an Address object as needed.  (Or you could do that from
within your controller too, I suppose.)


More information about the Catalyst mailing list