使用Bootstrap的simple_form复选框 [英] simple_form with Bootstrap check box
问题描述
我将Bootstrap与simple_form一起使用,我想在标签左侧内联我的记住我复选框,如Twitter Bootstrap文档中所示:http://twitter.github.com/bootstrap/base-css.html#forms
I'm using simple_form with Bootstrap and I would like to have my "Remember me" check box be inline to the left of the label, as in the Twitter Bootstrap docs: http://twitter.github.com/bootstrap/base-css.html#forms
我的表单代码如下:
<%= simple_form_for(resource, :as => resource_name, :url => session_path(resource_name), :html => { :class => 'well'}) do |f| %>
<%= f.input :email %>
<%= f.input :password %>
<%= f.input :remember_me, :as => :boolean if devise_mapping.rememberable? %>
<%= f.button :submit, "Sign In" %>
<% end %>
结果是复选框顶部的记住我标签。
The result is the the "Remember me" label on top of a check box.
我搞砸了什么?
推荐答案
有很多选项,请参见此处以了解更多信息:
There's a number of options for this, see here for more of them:
最直接(我认为)是使用:label => false
和:inline_label => true
,则可以更改标签在HTML中的放置位置。
The most straightforward (I think) is to use :label => false
and :inline_label => true
, on your checkbox, to change the where in the HTML the label is placed.
<%= f.input:remember_me,:as => :boolean,:label => false,:inline_label =>如果devise_mapping.rememberable是否为true? %>
对我来说,这是这样的:
This produces something like this for me:
这篇关于使用Bootstrap的simple_form复选框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!