Sha256: 32d64472f2225f213ea1519dc9cd5e239fc2a67f6b311f081192f9ba3f5204fe

Contents?: true

Size: 742 Bytes

Versions: 2

Compression:

Stored size: 742 Bytes

Contents

module Fields
  class TextController < ModelController
    def index
      # Default to text fields
      @type ||= 'text'
      @label ||= nil

      # Get the reactive manager for the value passed in
      manager = @value.reactive_manager

      # Find the parent reactive value that produced the value
      # (usually just model._field)
      @model = manager.parents[0].reactive_value

      # Get the name of the field by looking at the method scope
      @field_name = manager.scope[0]

      # Find the errors for this field
      @errors = @model.marked_errors[@field_name]
    end

    # When a field goes out of focus, then we want to start checking a field
    def blurred
      @model.mark_field!(@field_name)
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
volt-fields-0.0.2 app/fields/controllers/text_controller.rb
volt-fields-0.0.1 app/fields/controllers/text_controller.rb