If inline_label opt is true use default label text #553

Merged
merged 2 commits into from Apr 30, 2012

Projects

None yet

3 participants

@gmanley
Contributor
gmanley commented Apr 30, 2012

Have the inline label text be set to the default label text if the inline_label config is true.

@gmanley gmanley If inline_label opt is true use default label text
Have the inline label text be set to the default
label text if the inline_label config is true.
0c017e9
@gmanley
Contributor
gmanley commented Apr 30, 2012

I ran into a case where I just wanted to have the label be made inline without different text. Not sure if it makes sense to also disable the regular label if this option is set but here is the minimal change (which still requires the user to disable the label manually).

@rafaelfranca rafaelfranca commented on an outdated diff Apr 30, 2012
lib/simple_form/inputs/boolean_input.rb
@@ -3,9 +3,12 @@ module Inputs
class BooleanInput < Base
def input
if nested_boolean_style?
+ # If the inline_label option is a set to true then use the label_text as the inline_label
+ # otherwise use the specified object as the inline label (could be nil).
+ inline_label = options[:inline_label].eql?(true) ? label_text : options[:inline_label]
@rafaelfranca
rafaelfranca Apr 30, 2012 Collaborator
inline_label = options[:inline_label] == true ? label_text : options[:inline_label]
@rafaelfranca rafaelfranca commented on an outdated diff Apr 30, 2012
lib/simple_form/inputs/boolean_input.rb
@@ -3,9 +3,12 @@ module Inputs
class BooleanInput < Base
def input
if nested_boolean_style?
+ # If the inline_label option is a set to true then use the label_text as the inline_label
+ # otherwise use the specified object as the inline label (could be nil).
@rafaelfranca
rafaelfranca Apr 30, 2012 Collaborator

Remove these comments, the line above is self explanatory.

@rafaelfranca
Collaborator

Thank you. I added some comments inline.

About the label, I think that the user should disable it explicitly, because you can want sometimes a label in the left and in the right side in the same time.

@gmanley
Contributor
gmanley commented Apr 30, 2012

Just pushed up the necessary changes.

Cool, that makes sense.

@rafaelfranca
Collaborator

cc @carlosantoniodasilva can you review this one and merge? Thanks.

@carlosantoniodasilva
Collaborator

The api will look a little bit weird:

f.input :foo, label: false, inline_label: true

Anyway, I think that's fine, merging. Thanks :)

@carlosantoniodasilva carlosantoniodasilva merged commit 51fe90c into plataformatec:master Apr 30, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment