以 formattastic 访问表单对象

发布于 2024-09-25 04:28:04 字数 426 浏览 1 评论 0原文

所以我正在制作一个调查应用程序。用户在后端选择一种表单类型,并在前端显示为某种类型。当然,这只是理想情况。现在发生的情况是我无法访问 formtastic 正在为其构建表单的对象。我该怎么说“question.kind”之类的东西?这样只会犯错误。到目前为止,这是我所拥有的......

= semantic_form_for @survey, :url => "#", :html => { :method => "get" } do |f|
  - for question in @survey.questions
    = user_facing_question(f)

补充辅助方法到目前为止是这样的:

def user_facing_question(f)
  f.inputs
end

So I'm making a survey app. The users choose a type of form on the backend, and it displays as a certain type on the front end. That's only ideally, of course. What happens now is I can't access the object formtastic is building the form for. How can I say something like "question.kind"? It just makes an error that way. Here's what I have so far...

= semantic_form_for @survey, :url => "#", :html => { :method => "get" } do |f|
  - for question in @survey.questions
    = user_facing_question(f)

and the complementary helper method goes like this so far:

def user_facing_question(f)
  f.inputs
end

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(1

巷子口的你 2024-10-02 04:28:04

您可以访问表单的对象,例如:

f.object

You can access the form's object like:

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