Quoting Brett Sanger <[EMAIL PROTECTED]>:

> On Thu, Apr 03, 2003 at 10:19:25AM -0500, Steve Comrie wrote:
> > I've been using HTML::FillInForm to get this job, and other similar ones
> > done quickly and easily.
> 
> Ditto.  I'm not using HTML::Template, so I have my own output() routine
> to call Template Toolkit.  It's childsplay to put that output in a
> variable and run that through HTML::FillInForm before giving it to the
> screen/user.
> 
> Since I don't use HTML::Template, I don't recall if CGI::app's tie with
> it makes it more tricky to do that...I can't imagine it does, from what
> I recall.  You should be able to do the same.

It's quite easy actually.  I use something like the following (mostly from
memory and untested):

------------  Stick this is you Base class  -------------
sub form {
  my $self = shift;
  my $htmlref = shift;
  my $hashref = shift;
  my $fif = new HTML::FillInForm();
  if ($hashref) {
    # Use the hashref that was passed to fill in the form
    return $fif->fill(
            scalarref     => $htmlref,
            fdat          => $hashref,
    );
  } else {
    # Use the CGI query object to fill in the form
    return $fif->fill(
            scalarref     => $htmlref,
            fobject       => $self->query(),
            ignore_fields => ['rm']
    );
  }
}
----------------------------------------------------------

And then in your run mode just before you return the results of your template,
you send it through the 'form' method and return the results:

sub my_runmode {
  my $self = shift;
  # Do stuff...

  my %hash = (.....);
  my $html = $template->output();
  return $self->form(\$html, \%hash);
}

I think one of the advantages of the way all these modules have been designed is
that they follow the Unix mantra of making tools that do one task and do it
well.  This allows you to hook many of them together to do complex very tasks
with minimal fuss.  Here we have CGI::Application, HTML::Template and
HTML::FillInForm working in a very similar way that you might use something like 
ps, grep and cut to get process information.  I would probably throw
Data::FormValidator into this mix as well as a program that works well with others.

Kudos to the developers of these modules for keeping their focus on the task
they are trying to solve, and not throwing the kitchen sink into the mix...

Cees

---------------------------------------------------------------------
Web Archive:  http://www.mail-archive.com/[EMAIL PROTECTED]/
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to