class InputComponent
Constants
- MODIFIERS
Public Class Methods
new(type: nil, label: nil, value: nil, form: nil, fieldname: nil, collection: nil, modifiers: [], options: {})
click to toggle source
Calls superclass method
# File lib/alveole/components/input_component.rb, line 6 def initialize(type: nil, label: nil, value: nil, form: nil, fieldname: nil, collection: nil, modifiers: [], options: {}) super @label = label @form = form @fieldname = fieldname @collection = collection @options = options @options[:value] = value if value @type = type || :text @error_message = error_message modifiers << :error if error? modifiers << :disabled if options[:disabled] self.modifiers = modifiers end
Private Instance Methods
error?()
click to toggle source
# File lib/alveole/components/input_component.rb, line 31 def error? return false unless @form.object.respond_to? :errors @error ||= @form.object.errors.include?(@fieldname.to_s.sub(/_id$/, '')) end
error_message()
click to toggle source
# File lib/alveole/components/input_component.rb, line 37 def error_message return unless error? @error_message ||= @form.object.errors.messages_for(@fieldname.to_s.sub(/_id$/, '')).join(', ') end