If you have a form object with multiple config_file_paths, load_config_file (etc) don't behave in the same way as TT does when it has multiple directories in it's INCLUDE_PATH. I assume, possibly incorrectly, that that it should. What it does right now is take the list of directories, iterate through them attempting to load your config file, and if it does it happily continues through the list of paths, so if it finds another one, it'll use that one instead. TT uses the first one it finds, which allows you to have customized version of shared templates by customizing INCLUDE_PATH. We need to do the same thing with FormFu at $work, which is how we've run into this problem.

Attached is an svn diff for a new test which fails in the current version, and the corresponding fix for the problem.

Let me know if you need any clarification, or anything else, and thanks for the great package, it's save us tremendous amounts of time.

Adam
Index: t/config_file_path.t
===================================================================
--- t/config_file_path.t	(revision 1819)
+++ t/config_file_path.t	(working copy)
@@ -1,7 +1,7 @@
 use strict;
 use warnings;
 
-use Test::More tests => 3;
+use Test::More tests => 4;
 
 use File::Temp qw(tempdir);
 use HTML::FormFu;
@@ -35,3 +35,8 @@
 $form2->load_config_file('form.yml');
 ok( $form2->get_field('found-me') );
 
+my $form3 = HTML::FormFu->new;
+$form3->config_file_path([ 't/config_file_path2', @dirs, 't/config_file_path' ]);
+$form3->load_config_file('form.yml');
+ok( $form3->get_field('new-found-me') );
+
Index: t/config_file_path2/form.yml
===================================================================
--- t/config_file_path2/form.yml	(revision 0)
+++ t/config_file_path2/form.yml	(revision 0)
@@ -0,0 +1,3 @@
+---
+elements:
+    - name: new-found-me
Index: lib/HTML/FormFu/ObjectUtil.pm
===================================================================
--- lib/HTML/FormFu/ObjectUtil.pm	(revision 1819)
+++ lib/HTML/FormFu/ObjectUtil.pm	(working copy)
@@ -160,6 +160,7 @@
             my ( $filename, $filedata ) = %{ $config->[0] };
 
             _load_file( $self, $data_visitor, $filedata );
+            last;
         }
         croak "config file '$file' not found" if !$loaded;
     }
@@ -409,4 +410,4 @@
                          undef;
 }
 
-1;
\ No newline at end of file
+1;
_______________________________________________
HTML-FormFu mailing list
HTML-FormFu@lists.scsys.co.uk
http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/html-formfu

Reply via email to