Class: Fields::MainController
- Inherits:
-
Volt::ModelController
- Object
- Volt::ModelController
- Fields::MainController
- Defined in:
- app/fields/controllers/main_controller.rb
Direct Known Subclasses
CheckboxController, SelectRadioController, 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.
- #field_name ⇒ Object
- #label ⇒ Object
- #marked ⇒ Object
-
#model_inst ⇒ 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
45 46 47 |
# File 'app/fields/controllers/main_controller.rb', line 45 def blur model_inst.mark_field!(@field_name) end |
#errors ⇒ Object
Find the errors for this field
36 37 38 |
# File 'app/fields/controllers/main_controller.rb', line 36 def errors model_inst.marked_errors[@field_name] end |
#field_name ⇒ Object
40 41 42 |
# File 'app/fields/controllers/main_controller.rb', line 40 def field_name @field_name end |
#label ⇒ Object
29 30 31 32 33 |
# File 'app/fields/controllers/main_controller.rb', line 29 def label unless ['false','False'].include?(attrs.label) attrs.label || @field_name.titleize end end |
#marked ⇒ Object
49 50 51 |
# File 'app/fields/controllers/main_controller.rb', line 49 def marked model_inst.marked_fields[@field_name] end |
#model_inst ⇒ Object
Find the parent reactive value that produced the value (usually just model._field)
25 26 27 |
# File 'app/fields/controllers/main_controller.rb', line 25 def model_inst attrs.value_parent end |
#setup_field ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'app/fields/controllers/main_controller.rb', line 6 def setup_field # Default to text fields if attrs.respond_to?(:type) @type = attrs.type else @type = 'text' end unless attrs.value_last_method field_type = self.class.to_s.underscore.gsub(/[_]Controller$/, '') raise "a <:fields:#{field_type} tag was used without passing a value attribute" end # Get the name of the field by looking at the method scope @field_name = attrs.value_last_method.gsub(/^[_]/, '') end |