【问题标题】:How can I use best_in_place gem with Bootstrap Form controls?如何将 best_in_place gem 与 Bootstrap Form 控件一起使用?
【发布时间】:2018-12-04 07:55:20
【问题描述】:

我想将 best_in_place gem 与 Bootstrap 的表单控件一起使用。我似乎无法将两者结合起来。

我最好的地方sn-p

<div class="form-control" >
   <dt><%= best_in_place @user, :email, :as => :textarea %></dt>
</div>

我的引导程序 sn-p

<form>
   <div class="form-group">
     <label for="exampleFormControlInput1">Email address</label>
     <input type="email" class="form-control" id="exampleFormControlInput1" placeholder="name@example.com">
    </div>
</form>

https://getbootstrap.com/docs/4.0/components/forms/

https://github.com/bernat/best_in_place

有什么想法可以做到这一点吗?

这适用于验证

<form>
  <div class="form-group">
   <input type="email" class="form-control" >
  </div>
</form>

但是使用 best_in_place,Bootstrap 验证不起作用。

</form>
 <div class="form-control" input type="email" >
  <%= best_in_place @user, :email, :as => :input %>
 </div>
</form>

【问题讨论】:

    标签: html twitter-bootstrap best-in-place


    【解决方案1】:

    我最终使用了这个代码

    </form>
     <div class="form-control" input type="email" >
      <%= best_in_place @user, :email, :as => :input %>
     </div>
    </form>
    

    但使用另一种方法 (gem 'validates_email_format_of') 来验证输入,无法同时工作。

    【讨论】:

      【解决方案2】:
      <form>
      <div class="row">
         <div class="form-group">
           <label for="exampleFormControlInput1">Email address</label>
           <input type="email" class="form-control" id="exampleFormControlInput1" placeholder="name@example.com">
          </div>
       </div>
      </form>
      

      【讨论】:

      • 嗨 Ghost,我不确定你的 sn-p 有什么帮助,它和我之前的 Bootstrap sn-p 一样。我需要在引导表单中使用 best_in_place。
      • 哇,对不起,伙计,我认为你需要第二张图片设计
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2013-09-26
      • 1970-01-01
      • 1970-01-01
      • 2012-01-19
      • 1970-01-01
      • 1970-01-01
      • 2012-05-01
      相关资源
      最近更新 更多