lib/trestle/form/fields/form_group.rb in trestle-0.8.13 vs lib/trestle/form/fields/form_group.rb in trestle-0.9.0
- old
+ new
@@ -3,22 +3,20 @@
module Fields
class FormGroup < Field
WRAPPER_OPTIONS = [:help, :label, :hide_label]
def render
- options[:class] << 'has-error' if errors.any?
-
content_tag(:div, options.except(*WRAPPER_OPTIONS)) do
concat label unless options[:label] == false
concat template.capture(&block) if block
concat help_message if options[:help]
concat error_message if errors.any?
end
end
def help_message
- classes = ["help-block"]
+ classes = ["form-text"]
if options[:help].is_a?(Hash)
message = options[:help][:text]
classes << "floating" if options[:help][:float]
else
@@ -27,24 +25,29 @@
content_tag(:p, message, class: classes)
end
def error_message
- content_tag(:p, class: "help-block") do
+ content_tag(:p, class: "invalid-feedback") do
safe_join([icon("fa fa-warning"), errors.first], " ")
end
end
def label
builder.label(name, options[:label], class: ["control-label", ("sr-only" if options[:hide_label])].compact)
end
def defaults
- super.merge(class: ["form-group"])
+ Trestle::Options.new(class: ["form-group"])
end
- def extract_options!
- # Do not call super
+ protected
+ def extract_wrapper_options!
+ # Intentional no-op
+ end
+
+ def error_class
+ "has-error"
end
end
end
end
end