Skip to content

Instantly share code, notes, and snippets.

@davidlesches davidlesches/base_field.rb Secret
Created Dec 25, 2013

Embed
What would you like to do?
Yodlee and Rails Implementation, Part 3: Forms - app/models/yodlee/fields/base_field.rb
module Yodlee
module Fields
class BaseField
attr_reader :field
def initialize opts
@field = opts[:field]
@wrapper = opts[:wrapper]
end
def render
"
<div class='field'>
<label>#{label} #{asterisk}</label>
#{input}
</div>
" if required?
end
def label
field.displayName
end
def asterisk
field.isOptional ? '' : '*'
end
def requirement
field.isOptional ? 'optional' : 'required'
end
def required?
!field.isOptional
end
def size
field['size']
end
def maxlength
field.maxlength
end
def value
field.value
end
def name
name = field.valueIdentifier
if @wrapper.present?
@wrapper + '[' + name + ']'
else
name
end
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.