Hi there, I'm using Catalyst::Controller::HTML::FormFu, and specify config_file_path => MyApp->path_to("forms"), which is fine for when I use :FormConfig(), but when I use load_config_file(), things don't go so well when running under Apache, since the cwd is "/" (the HTML::FormFu doc says "relative paths are resolved from the current working directory").
I found "__path_to()__" but that seems like a bit of a hack, and means that your form config file path isn't centralised (having to specify it in each form). What do you think about moving config_file_path into HTML::FormFu? Something like this: ------8<------8<------8<------8<------8<------8<------8<------8<----- Index: lib/HTML/FormFu.pm =================================================================== --- lib/HTML/FormFu.pm (revision 1204) +++ lib/HTML/FormFu.pm (working copy) @@ -70,6 +70,7 @@ default_model tmp_upload_dir params_ignore_underscore + config_file_path _plugins ) ); @@ -1344,8 +1345,8 @@ --- load_config_file: ext.yml -Like perl's C<open> function, relative-paths are resolved from the current -working directory. +Relative paths are resolved from the L</config_file_path> directory if +it is set, otherwise from the current working directory. If you're using the C<FormConfig> action controller in L<Catalyst::Controller::HTML::FormFu>, see @@ -1412,6 +1413,14 @@ before L</process> is called (otherwise, call L</process> again before rendering the form). +=head2 config_file_path + +Arguments: $directory_name + +L</config_file_path> defines where configuration files will be +searched for, if an absolute path is not given to +L</load_config_file>. + =head2 indicator Arguments: $field_name Index: lib/HTML/FormFu/ObjectUtil.pm =================================================================== --- lib/HTML/FormFu/ObjectUtil.pm (revision 1204) +++ lib/HTML/FormFu/ObjectUtil.pm (working copy) @@ -470,6 +470,9 @@ my $config_any_method = $use_stems ? 'load_stems' : 'load_files'; for my $file (@filenames) { + if ($file !~ /^\// and $self->config_file_path) { + $file = $self->config_file_path . "/" . $file; + } my $config = Config::Any->$config_any_method( { $config_any_arg => [$file], use_ext => 1, Index: lib/HTML/FormFu/MultiForm.pm =================================================================== --- lib/HTML/FormFu/MultiForm.pm (revision 1204) +++ lib/HTML/FormFu/MultiForm.pm (working copy) @@ -48,6 +48,7 @@ nested_subscript default_model model_config auto_fieldset params_ignore_underscore tmp_upload_dir + config_file_path ); __PACKAGE__->mk_item_accessors qw( ------8<------8<------8<------8<------8<------8<------8<------8<----- Then, Catalyst::Controller::HTML::FormFu can be simplified, just passing config_file_path to HTML::FormFu: ------8<------8<------8<------8<------8<------8<------8<------8<----- Index: lib/Catalyst/Controller/HTML/FormFu.pm =================================================================== --- lib/Catalyst/Controller/HTML/FormFu.pm (revision 1204) +++ lib/Catalyst/Controller/HTML/FormFu.pm (working copy) @@ -189,6 +189,10 @@ $form->action( $action ); } + if ($config->{config_file_path}) { + $form->config_file_path($config->{config_file_path}); + } + my $context_stash = $config->{context_stash}; $form->stash->{$context_stash} = $self->{c}; weaken( $form->stash->{$context_stash} ); @@ -476,8 +480,8 @@ =head2 config_file_path -Location of the form config files, used when creating a form with the -C<FormConfig> action controller. +Location of the form config files, passed through to +L<HTML::FormFu/config_file_path>. Default Value: C<< $c->path_to( 'root', 'forms' ) >> @@ -508,7 +512,7 @@ # default_action_use_path => 1 leads to: $form->action = /foo/bar/1 -=haed2 model_stash +=head2 model_stash Arguments: \%stash_keys_to_model_names Index: lib/Catalyst/Controller/HTML/FormFu/Action/MultiFormConfig.pm =================================================================== --- lib/Catalyst/Controller/HTML/FormFu/Action/MultiFormConfig.pm (revision 1204) +++ lib/Catalyst/Controller/HTML/FormFu/Action/MultiFormConfig.pm (working copy) @@ -27,18 +27,14 @@ my $ext_regex = $config->{_file_ext_regex}; for my $file (@files) { - my $filepath = defined $config->{config_file_path} - ? $config->{config_file_path} ."/". $file - : $file; - - $c->log->debug( __PACKAGE__ ." searching for file '$filepath'" ) + $c->log->debug( __PACKAGE__ ." searching for file '$file'" ) if $c->debug; if ( $file =~ m/ \. $ext_regex \z /x ) { - $multi->load_config_file( $filepath ); + $multi->load_config_file( $file ); } else { - $multi->load_config_filestem( $filepath ); + $multi->load_config_filestem( $file ); } } Index: lib/Catalyst/Controller/HTML/FormFu/Action/FormConfig.pm =================================================================== --- lib/Catalyst/Controller/HTML/FormFu/Action/FormConfig.pm (revision 1204) +++ lib/Catalyst/Controller/HTML/FormFu/Action/FormConfig.pm (working copy) @@ -27,18 +27,14 @@ my $ext_regex = $config->{_file_ext_regex}; for my $file (@files) { - my $filepath = defined $config->{config_file_path} - ? $config->{config_file_path} ."/". $file - : $file; - - $c->log->debug( __PACKAGE__ ." loading config file '$filepath'" ) + $c->log->debug( __PACKAGE__ ." loading config file '$file'" ) if $c->debug; if ( $file =~ m/ \. $ext_regex \z /x ) { - $form->load_config_file( $filepath ); + $form->load_config_file( $file ); } else { - $form->load_config_filestem( $filepath ); + $form->load_config_filestem( $file ); } } ------8<------8<------8<------8<------8<------8<------8<------8<----- (also, note the typo fixed above =haed2 -> =head2) Regards, -- Geoffrey D. Bennett, RHCE, RHCX mailto:[EMAIL PROTECTED] Senior Systems Engineer sip:[EMAIL PROTECTED] NetCraft Australia Pty Ltd http://www.netcraft.com.au/geoffrey/ _______________________________________________ HTML-FormFu mailing list HTML-FormFu@lists.scsys.co.uk http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/html-formfu