package WebminUI::Form;
use WebminCore;
=head2 new WebminUI::Form(cgi, [method])
Creates a new form, which submits to the given CGI
=cut
sub new
{
if (defined(&WebminUI::Theme::Form::new)) {
return new WebminUI::Theme::Form(@_[1..$#_]);
}
my ($self, $program, $method) = @_;
$self = { 'method' => 'get',
'name' => "form".++$form_count };
bless($self);
$self->set_program($program);
$self->set_method($method) if ($method);
return $self;
}
=head2 html()
Returns the HTML that makes up this form
=cut
sub html
{
my ($self) = @_;
my $rv;
if ($self->get_align()) {
$rv .= "
\n";
}
$rv .= $self->form_start();
if ($self->get_heading()) {
if (defined(&ui_subheading)) {
$rv .= &ui_subheading($self->get_heading());
}
else {
$rv .= "
".$self->get_heading()."
\n";
}
}
# Add the sections
foreach my $h (@{$self->{'hiddens'}}) {
$rv .= &ui_hidden($h->[0], $h->[1])."\n";
}
foreach my $s (@{$self->{'sections'}}) {
$rv .= $s->html();
}
# Check if we have any inputs that need disabling
my @dis = $self->list_disable_inputs();
if (@dis) {
# Yes .. generate a function for them
$rv .= "\n";
}
# Add the buttons at the end of the form
my @buttonargs;
foreach my $b (@{$self->{'buttons'}}) {
if (ref($b)) {
# An array of inputs
my $ihtml = join(" ", map { $_->html() } @$b);
push(@buttonargs, $ihtml);
}
else {
# A spacer
push(@buttonargs, "");
}
}
$rv .= &ui_form_end(\@buttonargs);
if ($self->get_align()) {
$rv .= "\n";
}
# Call the Javascript disable function
if (@dis) {
$rv .= "\n";
}
return $rv;
}
sub form_start
{
my ($self) = @_;
return "