安装simple_form
gem 'simple_form'
因为我需要使用bootstrap,所以需要添加bootstrap支持
rails generate simple_form:install --bootstrap
让表单的label和input横向显示
修改config/initializers/simple_form_bootstrap.rb 中的
config.default_wrapper = :vertical_form 改为 config.default_wrapper = :horizontal_form
让radio_bottons 横向显示, 加入 wrapper: :horizontal_collection_inline
<%= f.input :is_show, as: :radio_buttons, collection: yes_no, wrapper: :horizontal_collection_inline, label: '是否显示' %>