Simple_form: Remove outer label for an inline checkbox with label

前端 未结 6 1488
盖世英雄少女心
盖世英雄少女心 2021-02-02 07:14

Using Simple_form 2.0.2

The simple form code using HAML:

= f.input :remember_me, as: :boolean, inline_label: \'Remember me\'

But it ren

6条回答
  •  故里飘歌
    2021-02-02 08:01

    Maybe too late, but inspired by gamov answer I have made this a custom wrapper from inline bootstrap checkbox in the initializer file 'config/simple_form_bootstrap.rb':

    config.wrappers :horizontal_radio_and_checkboxes, tag: 'div', class: 'form-group', error_class: 'has-error' do |b|
       b.use :html5
       b.optional :readonly
    
       b.use :label, class: 'col-sm-3 control-label'
       b.use :input
       b.use :error, wrap_with: { tag: 'span', class: 'help-block' }
       b.use :hint,  wrap_with: { tag: 'p', class: 'help-block' }
     end
    

    which generates this html:

     

提交回复
热议问题