Sha256: 29554da2094a0e3563443aa60cac62a4823dc47b64520dfa37c1f830381c06e8
Contents?: true
Size: 962 Bytes
Versions: 2
Compression:
Stored size: 962 Bytes
Contents
module Fields class TextController < ModelController reactive_accessor :blurred reactive_accessor :errors def index # Default to text fields if attrs.respond_to?(:type) @type = attrs.type else @type = 'text' end # Find the parent reactive value that produced the value # (usually just model._field) @model = attrs.value_parent # Get the name of the field by looking at the method scope @field_name = attrs.value_last_method end def label label = (attrs.respond_to?(:label) && attrs.label) unless @label label = @field_name.titleize end return label 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) self.blurred = true end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
volt-fields-0.0.7 | app/fields/controllers/text_controller.rb |
volt-fields-0.0.6 | app/fields/controllers/text_controller.rb |