2014-02-27 119 views
0

我有我的看法如下代碼:simple_form單選按鈕沒有對齊正確

<%= simple_form_for :phrase do |f| %> 
     <%= f.input :phrase, label: 'Phrase you would like to add:' %> 
     <%= f.input :emotion, collection: [[true, 'Positive'], [false, 'Negative']], as: :radio_buttons, label: 'Emotion', label_method: :last %> 
     <%= f.input :category, collection: @categories, as: :radio_buttons, label: 'Categories', label_method: :last %> 
     <%= f.hidden_field :comment_id, :value => @comment.id %> 
     <%= f.button :submit, 'Add to Dictionary' %> 
<% end %> 

的問題是與f.input :emotionf.input :category線。這兩種方法都產生單選按鈕,但在每種情況下,單選按鈕實際上都略高於後面的文本。就提交選項而言,表單可以正常工作,但按鈕並不與它們旁邊的文本排列在一起。

有關如何清理這些問題或讓這些按鈕與各自選項保持一致的建議?

回答

0

嘗試將item_wrapper_class: 'inline'添加到您的input

<%= f.input :emotion, collection: [[true, 'Positive'], [false, 'Negative']], as: :radio_buttons, label: 'Emotion', label_method: :last, item_wrapper_class: 'inline' %> 
+0

這個正確對齊的一切,但引起的單選按鈕/文本對以水平束起來。有沒有辦法做到這一點,但仍然有我的選擇在頁面上下垂直運行? – Luigi

0

試試這個:

<%= f.collection_radio_buttons :emotion, [[true, 'Positive'], [false, 'Negative']], :first, :last, label: 'Emotion' %>