Skip Menu |

This queue is for tickets about the HTML-FormFu CPAN distribution.

Report information
The Basics
Id: 43529
Status: resolved
Priority: 0/
Queue: HTML-FormFu

People
Owner: Nobody in particular
Requestors: dmaki [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: Wishlist
Broken in: (no value)
Fixed in: (no value)



Subject: RFE: Make HTML::FormFu able to cope with multiple config_file_path
As described in my email to the mailing list, I'd like to use multiple config_file_path for webapp with a plugin mechanism. attatched is a patch that allows config_file_paths to be an arrayref. can you please take a look?
Subject: multiple_config_file_path.patch
=== lib/HTML/FormFu/ObjectUtil.pm ================================================================== --- lib/HTML/FormFu/ObjectUtil.pm (revision 101119) +++ lib/HTML/FormFu/ObjectUtil.pm (local) @@ -470,30 +470,45 @@ my $config_any_arg = $use_stems ? 'stems' : 'files'; my $config_any_method = $use_stems ? 'load_stems' : 'load_files'; + my @config_file_path; + if (my $config_file_path = $self->config_file_path) { + if (ref $config_file_path eq 'ARRAY') { + push @config_file_path, @$config_file_path; + } else { + push @config_file_path, $config_file_path; + } + } + push @config_file_path, File::Spec->curdir; + for my $file (@filenames) { - my $config_file_path = $self->config_file_path; + my $loaded = 0; + my $fullpath; + foreach my $config_file_path (@config_file_path) { + if ( defined $config_file_path + && !File::Spec->file_name_is_absolute($file) + ) + { + $fullpath = File::Spec->catfile( $config_file_path, $file ); + } else { + $fullpath = $file; + } - if ( defined $config_file_path - && !File::Spec->file_name_is_absolute($file) - ) - { - $file = File::Spec->catfile( $config_file_path, $file ); - } - - my $config = Config::Any->$config_any_method( { - $config_any_arg => [$file], - use_ext => 1, - driver_args => { - General => { -UTF8 => 1 }, - }, - } ); + my $config = Config::Any->$config_any_method( { + $config_any_arg => [$fullpath], + use_ext => 1, + driver_args => { + General => { -UTF8 => 1 }, + }, + } ); - croak "config file '$file' not found" - if !@$config; - - my ( $filename, $filedata ) = %{ $config->[0] }; + next if ! @$config; - _load_file( $self, $data_visitor, $filedata ); + $loaded = 1; + my ( $filename, $filedata ) = %{ $config->[0] }; + + _load_file( $self, $data_visitor, $filedata ); + } + croak "config file '$file' not found" if !$loaded; } return $self;
I was about to make this request. I have multiple web applications which share a few forms (login page for example). Template Toolkit allows sharing a few common templates in this manner INCLUDE_PATH => [ File::Spec->catdir( $class->rootDirectory, 'root' ), File::Spec->catdir( $class->rootDirectory, '..', 'root-common' ) ], It would be very handy if FormFu had the ability to do something similar. Creating an empty config file with a load_config_file directive is pretty clumsy by comparison.
This patch has been applied as of HTML-FormFu 0.04000