package WebGUI::FormBuilder; use strict; use Moose; use MooseX::Storage; =head1 NAME WebGUI::FormBuilder - Build a form. Really. =head1 SYNOPSIS my $f = WebGUI::FormBuilder->new( $session, action => "/save", method => "GET" ); $f->addField( 'Button', # See WebGUI::Form::Button name => 'Submit', label => 'Submit', ); my $tab = $f->addTab( "properties", "Properties" ); # "default" tabset $tab->addField( 'Text', name => "title" ); $tab->addField( 'Text', name => "url" ); my $html = $f->toHtml; my $var = $f->toTemplateVars; =head1 DESCRIPTION FormBuilder is used to build forms. Forms are made up of fields, tabsets, and fieldsets. Forms can be exported directly to HTML, or they can be exported to template variables. =head1 SEE ALSO WebGUI::FormBuilder::Tabset WebGUI::FormBuilder::Fieldset WebGUI::FormBuilder::Role::HasFields =head1 ATTRIBUTES =head2 action The URL to submit the form to =cut has 'action' => ( is => 'rw' ); =head2 enctype The encoding type to use for the form. Defaults to "multipart/form-data". The other possible value is "application/x-www-form-urlencoded". =cut has 'enctype' => ( is => 'rw', default => 'multipart/form-data' ); =head2 method The HTTP method for the form. Defaults to POST. =cut has 'method' => ( is => 'rw', default => 'POST' ); =head2 name The name of the form. Not required, but recommended. =cut has 'name' => ( is => 'rw' ); =head2 extras Any extra things to add to the
'; return $html; } #---------------------------------------------------------------------------- =head2 getHeader ( ) Get the header for this form. =cut sub getHeader { my ( $self ) = @_; my @attrs = qw{ action method name enctype }; my $attrs = join " ", map { qq{$_="} . $self->$_ . qq{"} } grep { $self->$_ } @attrs; my $html = sprintf '