package MyApp::Form; use HTML::FormHandler::Moose; extends 'HTML::FormHandler'; has_field 'address' => ( type => 'Compound' ); has_field 'address.street'; has_field 'address.city'; has_field 'address.zip' => ( type => '+Zip' ); 1;The subfields are indicated by prefacing the field name with the name of the compound field and a dot. This form class will create a form with an 'address' field that contains an array of fields.
You can achieve the same thing by creating an 'Address' field:
package MyApp::Field::Address; use HTML::FormHandler::Moose; extends 'HTML::FormHandler::Field::Compound'; has_field => 'street'; has_field => 'city'; has_field => 'zip' => ( type => '+Zip' ); 1;(Where '+Zip' is a field class that you have written...) Then this field can be used in a form by simply doing:
has_field 'addresss' => ( type => '+Address' );This feels simple and straightforward and, for me at least, matches my conceptual model of a form better than nested forms.