2014-02-27 47 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' %>