add label_text method to single wrapper #617

Merged
merged 3 commits into from Apr 2, 2014

Conversation

Projects
None yet
5 participants
@NOX73
Contributor

NOX73 commented Jul 12, 2012

Set label_text for single wrapper it's very useful feature for me.

config.wrappers :example, :label_text => lambda { |label, required| "#{required} #{label}" } do |b|
  b.use :label
  b.use :input
end
lib/simple_form/components/labels.rb
@@ -30,7 +30,8 @@ def label
end
def label_text
- SimpleForm.label_text.call(raw_label_text, required_label_text).strip.html_safe
+ lt = options[:label_text] || SimpleForm.label_text

This comment has been minimized.

Show comment Hide comment
@rafaelfranca

rafaelfranca Jul 12, 2012

Collaborator

please rename the variable to label_text

@rafaelfranca

rafaelfranca Jul 12, 2012

Collaborator

please rename the variable to label_text

@rafaelfranca

This comment has been minimized.

Show comment Hide comment
@rafaelfranca

rafaelfranca Jul 12, 2012

Collaborator

Yes, seems useful.

WDYT @carlosantoniodasilva?

Collaborator

rafaelfranca commented Jul 12, 2012

Yes, seems useful.

WDYT @carlosantoniodasilva?

@rafaelfranca

This comment has been minimized.

Show comment Hide comment
@rafaelfranca

rafaelfranca Jul 12, 2012

Collaborator

Maybe we can kill the configuration to use only the wrapper option.

Collaborator

rafaelfranca commented Jul 12, 2012

Maybe we can kill the configuration to use only the wrapper option.

@carlosantoniodasilva

This comment has been minimized.

Show comment Hide comment
@carlosantoniodasilva

carlosantoniodasilva Jul 14, 2012

Collaborator

Might be useful yeah. A couple questions:

@NOX73 do you need different label_text for different forms? For instance, would make sense to have required+label in some forms, and label+required in others, given they're all in the same app? Wouldn't that lead to inconsistent ui? Can you show a real example where you'd make use of this option?

Also, doesn't it expose an api like this?

f.input :name, :label_text => ->(*) { "Super!" }

This is something we wouldn't like to have public accessible I think.

Collaborator

carlosantoniodasilva commented Jul 14, 2012

Might be useful yeah. A couple questions:

@NOX73 do you need different label_text for different forms? For instance, would make sense to have required+label in some forms, and label+required in others, given they're all in the same app? Wouldn't that lead to inconsistent ui? Can you show a real example where you'd make use of this option?

Also, doesn't it expose an api like this?

f.input :name, :label_text => ->(*) { "Super!" }

This is something we wouldn't like to have public accessible I think.

@NOX73

This comment has been minimized.

Show comment Hide comment
@NOX73

NOX73 Jul 16, 2012

Contributor

I need different label_text in different site area, it's frontend & backend. I need add ':' symbol to backend, but in front labels should be without ':'. I think it's bad that i can't define different view of label_text for different wrappers. In addition, this functionality does not interfere with existing, but complements.

Contributor

NOX73 commented Jul 16, 2012

I need different label_text in different site area, it's frontend & backend. I need add ':' symbol to backend, but in front labels should be without ':'. I think it's bad that i can't define different view of label_text for different wrappers. In addition, this functionality does not interfere with existing, but complements.

@carlosantoniodasilva

This comment has been minimized.

Show comment Hide comment
@carlosantoniodasilva

carlosantoniodasilva Sep 8, 2012

Collaborator

The idea is ok, but we need to give more thought to the wrappers to get all this done. We also have #622 which has similarities, trying to extend the wrappers api. We should think more carefully about a way to wrap all this into a big change for a next major version, so I'll leave the issue open.

@NOX73 thanks for your work on that, it'd be good if you could come up with some tests as well.

Collaborator

carlosantoniodasilva commented Sep 8, 2012

The idea is ok, but we need to give more thought to the wrappers to get all this done. We also have #622 which has similarities, trying to extend the wrappers api. We should think more carefully about a way to wrap all this into a big change for a next major version, so I'll leave the issue open.

@NOX73 thanks for your work on that, it'd be good if you could come up with some tests as well.

@NOX73

This comment has been minimized.

Show comment Hide comment
@NOX73

NOX73 Sep 11, 2012

Contributor

Done.

Contributor

NOX73 commented Sep 11, 2012

Done.

@kikyous

This comment has been minimized.

Show comment Hide comment
@kikyous

kikyous Mar 19, 2013

i need this feature in our project!!!

kikyous commented Mar 19, 2013

i need this feature in our project!!!

@cveneziani

This comment has been minimized.

Show comment Hide comment
@cveneziani

cveneziani Aug 22, 2013

I'm also interested by this feature.
I have the same use case as @NOX73. I need to have different label_text for frontend and backend forms which are not used by the same kind of users.

@carlosantoniodasilva how is the state of the art concerning your thoughts about wrappers since last year?

I'm also interested by this feature.
I have the same use case as @NOX73. I need to have different label_text for frontend and backend forms which are not used by the same kind of users.

@carlosantoniodasilva how is the state of the art concerning your thoughts about wrappers since last year?

@carlosantoniodasilva

This comment has been minimized.

Show comment Hide comment
@carlosantoniodasilva

carlosantoniodasilva Aug 22, 2013

Collaborator

@cveneziani we have the idea to extend the wrappers API to allow more configurations, but nothing concrete / done yet. I'd not expect this to happen for 3.0.x version of Simple Form, perhaps for 3.1 we can achieve something more configurable.

Collaborator

carlosantoniodasilva commented Aug 22, 2013

@cveneziani we have the idea to extend the wrappers API to allow more configurations, but nothing concrete / done yet. I'd not expect this to happen for 3.0.x version of Simple Form, perhaps for 3.1 we can achieve something more configurable.

@cveneziani

This comment has been minimized.

Show comment Hide comment
@cveneziani

cveneziani Aug 23, 2013

@carlosantoniodasilva Thanks for the news.
I hope this feature could be done for 3.1 release.
I'll follow the state of this feature.

@carlosantoniodasilva Thanks for the news.
I hope this feature could be done for 3.1 release.
I'll follow the state of this feature.

@rafaelfranca rafaelfranca self-assigned this Apr 2, 2014

rafaelfranca added a commit that referenced this pull request Apr 2, 2014

Merge pull request #617 from NOX73/master
add label_text method to single wrapper

Conflicts:
	lib/simple_form/components/labels.rb

rafaelfranca added a commit that referenced this pull request Apr 2, 2014

@rafaelfranca rafaelfranca merged commit 716b998 into plataformatec:master Apr 2, 2014

1 check passed

default The Travis build passed
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment