diff --git a/lib/WebGUI/FormBuilder.pm b/lib/WebGUI/FormBuilder.pm index 50ddee15a..aecd571a7 100644 --- a/lib/WebGUI/FormBuilder.pm +++ b/lib/WebGUI/FormBuilder.pm @@ -119,18 +119,21 @@ Return the HTML for the form =cut -override 'toHtml' => sub { +sub toHtml { my ( $self ) = @_; my @attrs = qw{ action method name enctype }; my $attrs = join " ", map { qq{$_="} . $self->$_ . qq{"} } grep { $self->$_ } @attrs; my $html = sprintf '
'; return $html; -}; +} #---------------------------------------------------------------------------- diff --git a/lib/WebGUI/FormBuilder/Role/HasFields.pm b/lib/WebGUI/FormBuilder/Role/HasFields.pm index a05cdb250..7481f86ee 100644 --- a/lib/WebGUI/FormBuilder/Role/HasFields.pm +++ b/lib/WebGUI/FormBuilder/Role/HasFields.pm @@ -11,6 +11,7 @@ has 'fields' => ( default => sub { [] }, ); +with 'WebGUI::FormBuilder::Role::HasObjects'; =head1 METHODS @@ -119,23 +120,5 @@ sub getFieldsRecursive { return $fields; } -#---------------------------------------------------------------------------- - -=head2 toHtml ( ) - -Render the fields in this part of the form. - -=cut - -override 'toHtml' => sub { - my ( $orig, $self ) = @_; - - my $html = super(); - for my $field ( @{$self->fields} ) { - $html .= $field->toHtmlWithWrapper; - } - - return $html; -}; 1; diff --git a/lib/WebGUI/FormBuilder/Role/HasObjects.pm b/lib/WebGUI/FormBuilder/Role/HasObjects.pm new file mode 100644 index 000000000..f0e89b349 --- /dev/null +++ b/lib/WebGUI/FormBuilder/Role/HasObjects.pm @@ -0,0 +1,14 @@ +package WebGUI::FormBuilder::Role::HasObjects; + +use Moose::Role; + +has 'objects' => ( + is => 'rw', + isa => 'ArrayRef[Object]', + default => sub { [] }, +); + +# Objects combines "fields", "fieldsets", and "tabsets" + +1; + diff --git a/lib/WebGUI/FormBuilder/Role/HasTabs.pm b/lib/WebGUI/FormBuilder/Role/HasTabs.pm index e31aeeb66..2ac147bd8 100644 --- a/lib/WebGUI/FormBuilder/Role/HasTabs.pm +++ b/lib/WebGUI/FormBuilder/Role/HasTabs.pm @@ -3,6 +3,7 @@ package WebGUI::FormBuilder::Role::HasTabs; use strict; use Moose::Role; +with 'WebGUI::FormBuilder::Role::HasObjects'; requires 'session', 'pack', 'unpack'; has 'tabs' => ( @@ -94,21 +95,4 @@ sub getTab { return $self->{_tabsByName}{$name}; } -#---------------------------------------------------------------------------- - -=head2 toHtml ( ) - -Render the tabs in this part of the form - -=cut - -override 'toHtml' => sub { - my ( $self ) = @_; - my $html = super(); - for my $tab ( @{$self->tabs} ) { - $html .= $tab->toHtml; - } - return $html; -}; - 1; diff --git a/lib/WebGUI/FormBuilder/Tabset.pm b/lib/WebGUI/FormBuilder/Tabset.pm new file mode 100644 index 000000000..8a5928f1c --- /dev/null +++ b/lib/WebGUI/FormBuilder/Tabset.pm @@ -0,0 +1,26 @@ +package WebGUI::FormBuilder::Tabset; + +use Moose; + +has 'tabs' => ( + is => 'rw', + isa => 'ArrayRef[WebGUI::FormBuilder::Tab]', +); + +has 'session' => ( + is => 'ro', + isa => 'WebGUI::Session', + required => 1, + weak_ref => 1, + traits => [ 'DoNotSerialize' ], +); + +with Storage( format => 'JSON' ); + + +sub toHtml { + # Render the entire tabset + +} + +1;