選択ボックスにCSSクラスを追加するにはどうすればよいですか?rails:選択ボックスにCSSクラスを追加する
私は、このコードは動作しません
<%= select_tag(:ptype, options_for_select(TourParticipation::PTYPES, selected: "traveler", disabled: "Role:", :class => "widens")) %>
を持っています。
選択ボックスにCSSクラスを追加するにはどうすればよいですか?rails:選択ボックスにCSSクラスを追加する
私は、このコードは動作しません
<%= select_tag(:ptype, options_for_select(TourParticipation::PTYPES, selected: "traveler", disabled: "Role:", :class => "widens")) %>
を持っています。
は、ドキュメントによるとselect tag docsあなたはオプションはので、これはそれを行う必要があるハッシュとしてそれを渡す必要があります。
<%= select_tag(:ptype, options_for_select(TourParticipation::PTYPES, selected: "traveler", disabled: "Role:"), {:class => "widens"}) %>
あなたは、次のようにこれを行うことができます:
<%= select_tag :ptype, options_for_select(TourParticipation::PTYPES, selected: "traveler", disabled: "Role:"), {class: "widens", multiple: false, id: ""} %>
これは、これを使用しapi docsです参照することができます。
間違った場所に閉じ括弧があります。 オプションをselect_tag
に渡す必要があります(options_for_select
ではなく)。だからこれは欲しい:
<%= select_tag(:ptype, options_for_select(TourParticipation::PTYPES, selected: "traveler", disabled: "Role:"), :class => "widens") %>