我正在使用狂欢引擎,并希望更改所有选择标记样式。所以我想在这个选择中添加一个类。我在rails 3.2和ruby 2.0.0-p0工作。该文件位于html.erb
<%= select "search", filter[:scope], labels.insert(0, [filter_title(filter[:name]), nil]), selected: params[:search][filter[:scope]] %>
我试过了
<%= select "search", filter[:scope], labels.insert(0, [filter_title(filter[:name]), nil]), selected: params[:search][filter[:scope]], {:class => "select2"} %>
这打破_filters.html.erb:10: syntax error, unexpected ')', expecting =>
...cope]], {:class => "select2"} );@output_buffer.safe_concat('
<%= select "search", filter[:scope], labels.insert(0, [filter_title(filter[:name]), nil]), selected: params[:search][filter[:scope]], :class => "select2" %>
这会运行但不会将类添加到选择标记
<%= select( filter[:scope], labels.insert(0, [filter_title(filter[:name]), nil]), selected: params[:search][filter[:scope]], {:prompt => "search"}, {:class => "select2"} )%>
这打破_filters.html.erb:10: syntax error, unexpected ',', expecting =>
...scope]], {:prompt => "search"}, {:class => "select2"}));@out...
我已经FormOptionsHelper
了{{1}},但似乎我正在使用选择标记的旧语法rails。我无法想象任何人有同样的问题吗?
答案 0 :(得分:0)
您的选择应如下所示: -
<%= select "search", filter[:scope], labels, {selected: params[:search][filter[:scope]]}, {class: "class"} %>
或具体
{selected: params[:search][filter[:scope]]}, {class: "class"}
这是最后一个参数