class EndView::Form::Builder
Public Instance Methods
auth_token_opts(opts = {})
click to toggle source
# File lib/end_view/form/builder.rb, line 16 def auth_token_opts(opts = {}) { name: 'auth_token', type: 'hidden', value: auth_token }.merge(opts) end
form_method_opts(opts = {})
click to toggle source
# File lib/end_view/form/builder.rb, line 22 def form_method_opts(opts = {}) { name: '_method', type: 'hidden', value: form_method }.merge(opts) end
form_opts(opts = {})
click to toggle source
# File lib/end_view/form/builder.rb, line 12 def form_opts(opts = {}) { action: form_url, method: 'post' }.merge(opts) end
input_opts(attribute, opts = {})
click to toggle source
# File lib/end_view/form/builder.rb, line 30 def input_opts(attribute, opts = {}) { id: attribute_id(attribute), name: attribute_name(attribute), type: 'text' }.merge(find_default(attribute)).merge(opts) end
label_opts(attribute, opts = {})
click to toggle source
# File lib/end_view/form/builder.rb, line 26 def label_opts(attribute, opts = {}) { for: attribute_id(attribute) }.merge(opts) end
Private Instance Methods
attribute_id(attribute)
click to toggle source
# File lib/end_view/form/builder.rb, line 38 def attribute_id(attribute) attribute.to_s end
attribute_name(attribute)
click to toggle source
# File lib/end_view/form/builder.rb, line 42 def attribute_name(attribute) attribute.to_s end
find_default(attribute)
click to toggle source
# File lib/end_view/form/builder.rb, line 58 def find_default(attribute) input_defaults.each { |k, v| return v if k.any? { |w| attribute =~ /#{w}/ } } {} end
input_defaults()
click to toggle source
# File lib/end_view/form/builder.rb, line 46 def input_defaults @input_defaults ||= { %w(email) => { type: 'email' }, %w(phone) => { type: 'tel' }, %w(password) => { type: 'password' }, %w(url) => { type: 'url' }, %w(search) => { type: 'search', placeholder: 'Search' }, %w(card) => { pattern: '[0-9]{13,16}', autocomplete: 'off' }, %w(security_code csc cvd cvn cvv cvc ccv spc) => { size: 5, autocomplete: 'off' } } end