diff --git a/lib/WebGUI/FormBuilder.pm b/lib/WebGUI/FormBuilder.pm index dc4cc1239..9e2d8bb01 100644 --- a/lib/WebGUI/FormBuilder.pm +++ b/lib/WebGUI/FormBuilder.pm @@ -4,10 +4,78 @@ 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 session + +A WebGUI::Session object. Required. + +=cut + has 'session' => ( is => 'ro', isa => 'WebGUI::Session', @@ -31,28 +99,8 @@ use WebGUI::FormBuilder::Fieldset; =head2 new ( session, properties ) -Create a new FormBuilder object. C is a list of name => value pairs - -=over 4 - -=item name - -The name of the form. Optional, but recommended. - -=item action - -The URL to submit the form to. - -=item method - -The HTTP method to submit the form with. Defaults to POST. - -=item enctype - -The encoding type to use for the form. Defaults to "multipart/form-data". The -other possible value is "application/x-www-form-urlencoded". - -=back +Create a new FormBuilder object. C is a list of name => value pairs of +attributes. =cut @@ -64,14 +112,6 @@ sub BUILDARGS { #---------------------------------------------------------------------------- -=head2 action ( [ newAction ] ) - -Get or set the action property / HTML attribute. - -=cut - -#---------------------------------------------------------------------------- - =head2 clone ( ) Create a clone of this Form @@ -84,14 +124,6 @@ sub clone { #---------------------------------------------------------------------------- -=head2 enctype ( [ newEnctype ] ) - -Get or set the enctype property / HTML attribute. - -=cut - -#---------------------------------------------------------------------------- - =head2 getFooter ( ) Get the footer for this form. @@ -127,30 +159,6 @@ sub getHeader { #---------------------------------------------------------------------------- -=head2 method ( [ newMethod ] ) - -Get or set the method property / HTML attribute. - -=cut - -#---------------------------------------------------------------------------- - -=head2 name ( [ newName ] ) - -Get or set the name property / HTML attribute. - -=cut - -#---------------------------------------------------------------------------- - -=head2 session ( ) - -Get the WebGUI::Session attached to this object - -=cut - -#---------------------------------------------------------------------------- - =head2 toHtml ( ) Return the HTML for the form diff --git a/lib/WebGUI/FormBuilder/Tabset.pm b/lib/WebGUI/FormBuilder/Tabset.pm index 6e5339785..f3ab4fb2b 100644 --- a/lib/WebGUI/FormBuilder/Tabset.pm +++ b/lib/WebGUI/FormBuilder/Tabset.pm @@ -4,18 +4,64 @@ use Moose; use MooseX::Storage; use WebGUI::FormBuilder::Tab; +=head1 NAME + +WebGUI::FormBuilder::Tabset - A set of tabs + +=head1 SYNOPSIS + + my $tabset = WebGUI::FormBuilder::Tabset->new( $session, name => "properties" ); + my $tab = $tabset->addTab( WebGUI::FormBuilder::Tab->new( $session, name => "normal" ) ); + + # Using FormBuilder + my $f = WebGUI::FormBuilder->new( $session ); + $f->addTabset( name => "properties" ); + $f->addTab( name => "normal", tabset => "properties" ); + +=head1 DESCRIPTION + +A tabset holds tabs. It does nothing else. Tabs can in turn hold fields, fieldsets, +or other tabsets. + +Tabs are displayed using YUI TabView. + +=head1 SEE ALSO + + WebGUI::FormBuilder + WebGUI::FormBuilder::Tab + +=head1 ATTRIBUTES + +=head2 name + +A name string. Required. + +=cut + has 'name' => ( is => 'ro', isa => 'Str', required => 1, ); +=head2 tabs + +The array of tabs this tabset contains. + +=cut + has 'tabs' => ( is => 'rw', isa => 'ArrayRef', default => sub { [] }, ); +=head2 session + +The WebGUI::Session object. Required. + +=cut + has 'session' => ( is => 'ro', isa => 'WebGUI::Session', @@ -33,14 +79,6 @@ with 'WebGUI::FormBuilder::Role::HasObjects'; Create a new Tabset object. C is a list of name => value pairs -=over 4 - -=item name - -The name of the tabset. Required. - -=back - =cut sub BUILDARGS {