在 Catalyst::Controller::Formbuilder 中配置 form_path
使用 Catalyst::Controller::FormBuilder
模块处理 Catalyst 应用程序中的表单。
文档说你可以像这样设置 form_path:
form_path =>; File::Spec->catfile( $c->config->{home}, 'root', 'forms' )
,
但是我的应用程序中对 config() 的调用位于顶层的基本模块。因此,$c 是未定义的。所以我无法调用$c->config->{home}。
配置 form_path 的正确方法是什么?
Using the Catalyst::Controller::FormBuilder
module to handle forms in a Catalyst application.
The documentation says you can set the form_path like this:
form_path => File::Spec->catfile( $c->config->{home}, 'root', 'forms' )
,
But the call to config() in my application is at the top level of the base module. Therefore, $c is undefined. So I can't call $c->config->{home}.
What is the proper way to configure form_path please?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您应该能够使用 __PACKAGE__->config 哈希访问已从应用程序主模块设置的配置值。示例:
__PACKAGE__->config->{home}
或__PACKAGE__->config->{'Controller::FormBuilder'}->{form_path}
。如果您尝试在应用程序主模块中设置 FormBuilder 配置,则应该能够使用文档中提供的代码,只需替换
$c->config->{home}
与__PACKAGE__->config->{home}
。我认为他们甚至可能因为不这样做而犯了一个错误,但我不确定。You should be able to access configuration values that have already been set from your application's main module using the
__PACKAGE__->config
hash. Example:__PACKAGE__->config->{home}
or__PACKAGE__->config->{'Controller::FormBuilder'}->{form_path}
.If you're trying to set the FormBuilder configuration in your applications main module, you should be able to use the code provided in the documentation and just replace
$c->config->{home}
with__PACKAGE__->config->{home}
. I think they might have even made a mistake by not doing it this way, but I'm not sure.