Class: Fields::TextController

Inherits:
ModelController
  • Object
show all
Defined in:
app/fields/controllers/text_controller.rb

Direct Known Subclasses

TextareaController

Instance Method Summary collapse

Instance Method Details

#blurredObject

When a field goes out of focus, then we want to start checking a field



23
24
25
# File 'app/fields/controllers/text_controller.rb', line 23

def blurred
  @model.mark_field!(@field_name)
end

#indexObject



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'app/fields/controllers/text_controller.rb', line 3

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