moving to tabsets and ordered everything
This commit is contained in:
parent
631f6ad267
commit
db785fbc02
5 changed files with 48 additions and 38 deletions
|
|
@ -119,18 +119,21 @@ Return the HTML for the form
|
||||||
|
|
||||||
=cut
|
=cut
|
||||||
|
|
||||||
override 'toHtml' => sub {
|
sub toHtml {
|
||||||
my ( $self ) = @_;
|
my ( $self ) = @_;
|
||||||
|
|
||||||
my @attrs = qw{ action method name enctype };
|
my @attrs = qw{ action method name enctype };
|
||||||
my $attrs = join " ", map { qq{$_="} . $self->$_ . qq{"} } grep { $self->$_ } @attrs;
|
my $attrs = join " ", map { qq{$_="} . $self->$_ . qq{"} } grep { $self->$_ } @attrs;
|
||||||
|
|
||||||
my $html = sprintf '<form %s>', $attrs;
|
my $html = sprintf '<form %s>', $attrs;
|
||||||
$html .= super();
|
|
||||||
|
# Add individual objects
|
||||||
|
$html .= join "", map { $_->toHtml } @{$self->objects};
|
||||||
|
|
||||||
$html .= '</form>';
|
$html .= '</form>';
|
||||||
|
|
||||||
return $html;
|
return $html;
|
||||||
};
|
}
|
||||||
|
|
||||||
#----------------------------------------------------------------------------
|
#----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -11,6 +11,7 @@ has 'fields' => (
|
||||||
default => sub { [] },
|
default => sub { [] },
|
||||||
);
|
);
|
||||||
|
|
||||||
|
with 'WebGUI::FormBuilder::Role::HasObjects';
|
||||||
|
|
||||||
=head1 METHODS
|
=head1 METHODS
|
||||||
|
|
||||||
|
|
@ -119,23 +120,5 @@ sub getFieldsRecursive {
|
||||||
return $fields;
|
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;
|
1;
|
||||||
|
|
|
||||||
14
lib/WebGUI/FormBuilder/Role/HasObjects.pm
Normal file
14
lib/WebGUI/FormBuilder/Role/HasObjects.pm
Normal file
|
|
@ -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;
|
||||||
|
|
||||||
|
|
@ -3,6 +3,7 @@ package WebGUI::FormBuilder::Role::HasTabs;
|
||||||
use strict;
|
use strict;
|
||||||
use Moose::Role;
|
use Moose::Role;
|
||||||
|
|
||||||
|
with 'WebGUI::FormBuilder::Role::HasObjects';
|
||||||
requires 'session', 'pack', 'unpack';
|
requires 'session', 'pack', 'unpack';
|
||||||
|
|
||||||
has 'tabs' => (
|
has 'tabs' => (
|
||||||
|
|
@ -94,21 +95,4 @@ sub getTab {
|
||||||
return $self->{_tabsByName}{$name};
|
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;
|
1;
|
||||||
|
|
|
||||||
26
lib/WebGUI/FormBuilder/Tabset.pm
Normal file
26
lib/WebGUI/FormBuilder/Tabset.pm
Normal file
|
|
@ -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;
|
||||||
Loading…
Add table
Add a link
Reference in a new issue