访问formtastic中的表单对象

时间:2022-06-01 20:30:02

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...

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

= 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

1 个解决方案

#1


25  

You can access the form's object like:

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

f.object

#1


25  

You can access the form's object like:

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

f.object