在 Catalyst::Controller::Formbuilder 中配置 form_path

发布于 2024-08-09 05:22:05 字数 353 浏览 2 评论 0原文

使用 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

鱼忆七猫命九 2024-08-16 05:22:05

您应该能够使用 __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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文