class Furatto::FormBuilder
Public Instance Methods
label(attribute, text = nil, options = {})
click to toggle source
Calls superclass method
# File lib/furatto_rails_helpers/form_builder.rb, line 19 def label(attribute, text = nil, options = {}) options[:class] ||= "" options[:class] += " error" if has_error?(attribute) super(attribute, (text || "").html_safe, options) end
password_field(attribute, options = {})
click to toggle source
Calls superclass method
# File lib/furatto_rails_helpers/form_builder.rb, line 25 def password_field(attribute, options = {}) field attribute, options do |options| super(attribute, options.merge(:autocomplete => :off)) end end
Private Instance Methods
error_and_hint(attribute, options = {})
click to toggle source
# File lib/furatto_rails_helpers/form_builder.rb, line 45 def error_and_hint(attribute, options = {}) html = "" html += error_for(attribute, options) || "" html.html_safe end
error_for(attribute, options = {})
click to toggle source
# File lib/furatto_rails_helpers/form_builder.rb, line 37 def error_for(attribute, options = {}) if has_error?(attribute) error_messages = object.errors[attribute].join(', ') error_messages = error_messages.html_safe if options[:html_safe_errors] content_tag(:span, error_messages, :class => "error help-hint") end end
field(attribute, options) { |options| ... }
click to toggle source
# File lib/furatto_rails_helpers/form_builder.rb, line 51 def field(attribute, options, &block) html = ''.html_safe options[:class] = " error" if has_error?(attribute) html += yield(options) html += error_and_hint(attribute, options) end
has_error?(attribute)
click to toggle source
# File lib/furatto_rails_helpers/form_builder.rb, line 33 def has_error?(attribute) object.respond_to?(:errors) && !object.errors[attribute].blank? end