[html-formfu] variable form config file

Octavian Râsnita orasnita at gmail.com
Tue Dec 29 10:40:33 GMT 2009


From: "Steve Rippl" <rippls at woodlandschools.org>

> Hi,
> 
> I'm using Catalyst and FormFu, and I've found I can vary the config file 
> used with
> 
> sub controller_name :Local :Formconfig('/path/to/file.yml')
> 
> Can I set that file name using a variable, essentially off one of the 
> url args, so that I could use a different file depending on the variable 
> passed?  I'd like to parse different files under different conditions 
> but not build all new controllers for each case.
> 
> Thanks, and seasons greetings!


Hi,

You can use something like this:

package MyApp::Controller::Test;
use base 'Catalyst::Controller::HTML::FormFu';

sub action : Local {
  my ($self, $c, $template) = @_;

  my $form = $self->form;
  $form->load_config_filestem($template);
  $form->process;
  $c->stash(form => $form);
}

And you could access it at an URL like:

http://www.site.com/test/action/user

It will display the form user.yaml (or user.conf).

Octavian




More information about the HTML-FormFu mailing list