Sha256: b2c144638649ce911c0d4baeffed484a88670dbece810ddca0f48ba71fce5e8c
Contents?: true
Size: 909 Bytes
Versions: 2
Compression:
Stored size: 909 Bytes
Contents
module Fields class MainController < Volt::ModelController before_action :setup_field 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 # Find the parent reactive value that produced the value # (usually just model._field) def model attrs.value_parent end def label attrs.label || @field_name.titleize end # Find the errors for this field def errors model.marked_errors[@field_name] end # When a field goes out of focus, then we want to start checking a field def blur model.mark_field!(@field_name) end def marked model.marked_fields[@field_name] end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
volt-fields-0.1.2 | app/fields/controllers/main_controller.rb |
volt-fields-0.1.1 | app/fields/controllers/main_controller.rb |