【问题标题】:How to use bootstrap class in best_in_place gem rails 6?如何在 best_in_place gem rails 6 中使用引导类?
【发布时间】:2021-05-05 13:10:04
【问题描述】:

我试图在文本字段中提供引导类form-control,但它不起作用。 代码:

 <% @user.each do |record| %>    
   <tr>
    <td>
      <%= best_in_place record, :name, :as => :input %> 
   </td>
   <td>
     <%= best_in_place record, :gender, :as => :select, collection: (MUser.pluck(:id, 
     :gender)), inner_class: 'form-control %>
   </td>
   <td>
     <%= best_in_place record, :dob, :as => :date, class: 'datepicker1 %>
   </td>
 </tr>
<% end %>

如何在 best_in_place 字段中提供引导类?

【问题讨论】:

  • @Nitin Srivastava 先生,请也检查一下。

标签: ruby-on-rails best-in-place


【解决方案1】:

首先,您需要根据输入类型找出引导类。例如对于text 字段,我们有form-control 类,而对于select,我们有custom-select 类。

根据字段类型使用这些类。这是代码 sn-p 可能会对您有所帮助。

<td>
  <%= best_in_place record, :name, as: :input, inner_class: 'form-control' %> 
</td>
<td>
  <%= best_in_place record, :gender, as: :select, collection: (MUser.pluck(:id, 
 :gender)), inner_class: 'custom-select' %>
</td>

快乐编码:)

【讨论】:

    猜你喜欢
    • 2012-01-19
    • 1970-01-01
    • 1970-01-01
    • 2012-11-15
    • 1970-01-01
    • 2013-03-06
    • 2014-06-23
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多