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:
parent
c61b7499a5
commit
da0463b9d6
3 changed files with 8 additions and 1 deletions
|
@ -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
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue