1
0
Fork 0
mirror of https://github.com/heartcombo/simple_form.git synced 2022-11-09 12:19:26 -05:00

Adding label class configuration option

This commit is contained in:
Rodrigo Navarro 2011-02-08 07:42:18 +08:00 committed by Carlos Antonio da Silva
parent c61b7499a5
commit da0463b9d6
3 changed files with 8 additions and 1 deletions

View file

@ -52,6 +52,9 @@ SimpleForm.setup do |config|
# How the label text should be generated altogether with the required text.
# config.label_text = lambda { |label, required| "#{required} #{label}" }
# You can define the class to use on all labels. Default is nil.
# config.label_class = nil
# Whether attributes are required by default (or not). Default is true.
# config.required_by_default = true

View file

@ -79,6 +79,10 @@ module SimpleForm
mattr_accessor :label_text
@@label_text = lambda { |label, required| "#{required} #{label}" }
# You can define the class to use on all labels. Default is nil.
mattr_accessor :label_class
@@label_class = nil
# Whether attributes are required by default (or not).
mattr_accessor :required_by_default
@@required_by_default = true

View file

@ -36,7 +36,7 @@ module SimpleForm
end
def label_html_options
label_options = html_options_for(:label, [input_type, required_class])
label_options = html_options_for(:label, [input_type, required_class, SimpleForm.label_class])
label_options[:for] = options[:input_html][:id] if options.key?(:input_html) && options[:input_html].key?(:id)
label_options
end