1

私は持っています

<%= f.input :user_type, :label_html => { :class => 'option_label_name' }, :label => "User Type" ,:collection => [["Master"], ["HO Administrator"], ["Practice Manager"], ["Branch Administrator"], ["Consultant"]], :include_blank => false %>
</div>

これにより、多くのオプションを含むリストが作成されますが、コレクション要素のみにcssスタイリングクラスを提供する方法があるかどうかを知りたいです...

現在のフォームと同様に、スタイリングはラベルにのみ提供され、オプションは提供されません...

私は1つの解決策を見つけました...それは私が探していたものではありませんが、これは機能します。

<div id="innerblock_left">
<%= f.label :user_type, :class =>"label_name", :label => "User Type" %>
<select class="style2">
<option value="1">Master</option>
<option value="2">HO Administrator</option>
<option value="3">Practice Manager</option>
<option value="4">Branch Administrator</option>
<option value="5">Consultant</option>
</select>
</div>

誰かが単純なフォームコレクション要素にスタイリングを提供する方法を知っていれば素晴らしいと思いますが...

読んでくれてありがとう..

4

1 に答える 1

0

0単純な解決策:

フォームヘルパーで、コレクションを定義します。

def list
  [["Master",:class => "d_1"], ["HO Administrator",:class => "d_2"], ["Practice Manager",:class => "d_0"],["Branch Administrator",:class => "d_2"], ["Consultant",:class => "d_2"]]
end

あなたの形で:

<%= f.input :user_type, :label_html => { :class => 'option_label_name' }, :label => "User Type" ,:collection => list, :include_blank => false %>

アセットにCSSトリックを追加します。

.d_0 {
  font-weight: bold; }
.d_1{
  font-style: italic;
  text-decoration: underline;
  padding-left: 10px;}
.d_2 {
  font-style: italic;
  padding-left: 20px;}
于 2012-08-19T08:30:58.707 に答える