我在使用formtastic创建以下内容时遇到了问题。这是一个简单的表单,但它不是基于完整的资源,只是我想发送的查询字符串参数。
# index.html.haml
...
= form_tag resources_path, :method => 'get' do |f|
= label_tag 'filter', 'Filter'
= text_field_tag(:filter, params[:filter])
= submit_tag('Go', :name => nil)
Formtastic在这里可能有些过分,但如果可能的话,使用一致的语义会很好。
您如何将上述内容翻译成formtastic语法?
答案 0 :(得分:0)
你看到了这些RailsCasts:
http://railscasts.com/episodes/184-formtastic-part-1
http://railscasts.com/episodes/185-formtastic-part-2
https://github.com/justinfrench/formtastic/wiki/4-Formtastic-Options
应该是这样的:
= semantic_form_for @your_model do |f|
= f.inputs
= f.buttons
或者这个:
= semantic_form_for @your_model do |f|
= f.input :filter
= f.commit_button :label => "Go"
然后运行rails g formtastic/stylesheets
并将它们添加到样式表/资产管道中。
您还需要在应用程序布局中包含这些额外的Formtastic样式表。
请查看上面的RailsCasts了解详情