Class: Fields::MainController
- Inherits:
-
Volt::ModelController
- Object
- Volt::ModelController
- Fields::MainController
- Defined in:
- app/fields/controllers/main_controller.rb
Direct Known Subclasses
CheckboxController, RadioController, SelectController, TextController, TextareaController
Instance Method Summary collapse
-
#blur ⇒ Object
When a field goes out of focus, then we want to start checking a field.
-
#errors ⇒ Object
Find the errors for this field.
- #label ⇒ Object
- #marked ⇒ Object
-
#model ⇒ Object
Find the parent reactive value that produced the value (usually just model._field).
- #setup_field ⇒ Object
Instance Method Details
#blur ⇒ Object
When a field goes out of focus, then we want to start checking a field
33 34 35 |
# File 'app/fields/controllers/main_controller.rb', line 33 def blur model.mark_field!(@field_name) end |
#errors ⇒ Object
Find the errors for this field
28 29 30 |
# File 'app/fields/controllers/main_controller.rb', line 28 def errors model.marked_errors[@field_name] end |
#label ⇒ Object
23 24 25 |
# File 'app/fields/controllers/main_controller.rb', line 23 def label attrs.label || @field_name.titleize end |
#marked ⇒ Object
37 38 39 |
# File 'app/fields/controllers/main_controller.rb', line 37 def marked model.marked_fields[@field_name] end |
#model ⇒ Object
Find the parent reactive value that produced the value (usually just model._field)
19 20 21 |
# File 'app/fields/controllers/main_controller.rb', line 19 def model attrs.value_parent end |
#setup_field ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 |
# File 'app/fields/controllers/main_controller.rb', line 5 def setup_field # Default to text fields if attrs.respond_to?(:type) @type = attrs.type else @type = 'text' end # Get the name of the field by looking at the method scope @field_name = attrs.value_last_method.gsub(/^[_]/, '') end |