Search code examples
ruby-on-railshamlsimple-form

Wrapping 'simple form'


I cannot produce this output with simple form:

.row
  .checkbox.check-default
    %input#checkbox1{:checked => "checked", :type => "checkbox", :value => "1"}/
    %label{:for => "checkbox1"} Keep Me Signed in

My current wrapper:

config.wrappers :inline_checkbox, :tag => 'div', :class => 'checkbox check-default', :error_class => 'error' do |b|
  b.use :html5
  b.use :label_input, :wrap_with => { :class => 'checkbox inline' }
end

UPDATE

I accidently overlooked the following:

  # Define the way to render check boxes / radio buttons with labels.
  # Defaults to :nested for bootstrap config.
  #   inline: input + label
  #   nested: label > input
  config.boolean_style = :inline

i had a second initializer... thanks for pointing me in the right direction..


Solution

  • I'm not an expert but keep in mind that :label_input outputs label and input together in default order. Maybe you should try:

    config.wrappers :inline_checkbox, :tag => 'div', :class => 'checkbox check-default', :error_class => 'error' do |b|
      b.use :html5
      b.use :input
      b.use :label
    end