4

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 はおそらくやり過ぎですが、可能であれば一貫したセマンティクスを使用することをお勧めします。

上記をどのように形式的な構文に変換しますか?

4

1 に答える 1

0

これらのRailsCastを見ましたか:

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 を確認してください。

于 2011-10-11T07:22:55.927 に答える