Sha256: d43638d526e7543c053242c8b3588dee69a8a874bda11acabdd7cc91dcd8a7b0
Contents?: true
Size: 968 Bytes
Versions: 2
Compression:
Stored size: 968 Bytes
Contents
module Fields class TextController < Volt::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.9 | app/fields/controllers/text_controller.rb |
volt-fields-0.0.8 | app/fields/controllers/text_controller.rb |