How to use bootstrap class in best_in_place gem rails 6?

140 Views Asked by At

I am trying to give bootstrap class form-control in text field, but it didn't works. Code:

 <% @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 %>

how can i give bootstrap class in best_in_place fields?

1

There are 1 best solutions below

0
Nitin Srivastava On

First you need to find out bootstrap classes based on input type. For example for text field we have form-control class while for select we have custom-select class.

Use these classes based on the field type. Here is code snippet which may help you.

<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>

enter image description here enter image description here Happy coding :)