Skip to content

Default checkboxes should have labels on the left #670

Closed
kwerle opened this Issue Oct 4, 2012 · 6 comments

3 participants

@kwerle
kwerle commented Oct 4, 2012

(HAML notation)

If I have

    = f.input :some_boolean

then I expect

    <div class="input boolean optional"><input name="some_model[some_boolean]" type="hidden" value="0" /><label class="boolean optional control-label checkbox" for="some_model_some_boolean">Some Boolean<input checked="checked" class="boolean optional" id="some_model_some_boolean" name="some_model[some_boolean]" type="checkbox" value="1" /></label></div>
@rafaelfranca

I think you can archive this creating a new wrapper to checkboxes:

config.wrappers :checkbox do |b|
  b.use :label
  b.use :input
end

and use it

= f.input :some_boolean, :wrapper => :checkbox
@nashby
nashby commented Oct 4, 2012

Also you can use this wrapper for all boolean fields if you are using SimpleForm 2.0.3. Just add it to your initializer:

config.wrapper_mappings = { :boolean => :checkbox }

so you don't need to specify it for each input.

@kwerle
kwerle commented Oct 4, 2012

That's nice, and I'll try it and let you know. But here is what I expect:
Labels are on the left by default. For everything, including checkboxes.
Failing that, I'd like to see the following work:

  = f.input :some_boolean, label_on: :left

And if the default is that they are on the left, I would like to see

  = f.input :some_boolean, label_on: :right

do what I expect. Both those options should work and be well documented.

This seems obvious and important to me, so I'm more than willing to put some time into making it work if it's something that might get integrated.

@rafaelfranca

I disagree. every web site that I see use labels in the right when using check boxes and radio buttons.

Plus, I strongly -1 for adding new options if you can do in other way.

@kwerle
kwerle commented Oct 4, 2012

Checkboxes that are used to make selections are often labeled on the right.
Checkboxes that are used for boolean on/off values are often labeled on the left.

As for "doing it another way", google for simple_form and label left:
https://www.google.com/search?q=simple_form+label+left&oq=simple_form+label+left
yields nothing but bug reports and requests and information that does not seem to work (having tried all the various recommendations up to now).

label_on: :left|:right
seems like an obvious solution to an obvious problem.

Adding a custom renderer and using :checkbox instead of :boolean seems like a hack whose intention is not clear.

@rafaelfranca

Sorry but I still didn't buy add a new option. Right now you can do:

config.wrappers :left_label do |b|
  b.use :label
  b.use :input
end

config.wrapper_mappings = { :boolean => :left_label }

If you need the label in the left.

This is not a common use case so I don't think we should add a special option to it.

@MargaretLangley MargaretLangley referenced this issue in BCS-io/schedule_gardener Aug 17, 2015
Closed

Checkbox should be on the left had side #109

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.