使用Bootstrap的simple_form复选框 [英] simple_form with Bootstrap check box

查看:70
本文介绍了使用Bootstrap的simple_form复选框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我将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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆