2012-08-13 49 views
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樣式類只集合元素...

正如造型只提供給標籤,而不是選擇當前表單...

我已經找到一個解決方案..這不是我正在尋找的那個,但是這確實起作用..

<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> 

雖然它會如果,如果有人知道如何提供造型以簡單的形式集合元素大...

感謝您閱讀..

回答

0

0Just一個簡單的解決方案:

在表單幫手,定義集合:

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;} 
相關問題