class Conjoin::FormBuilder::Input
Attributes
app[RW]
data[RW]
options[RW]
record[RW]
Public Class Methods
new(data, app, record)
click to toggle source
# File lib/conjoin/form_builder.rb, line 302 def initialize data, app, record @data = data @app = app @record = record @options = { name: data.name, type: :text, id: id, value: data.value, class: '' }.merge! data.options options[:class] += ' form-control' @options end
Public Instance Methods
display()
click to toggle source
# File lib/conjoin/form_builder.rb, line 341 def display append_button = options.delete :append_button if append_button mab do div class: 'input-group' do input options div class: 'input-group-btn' do button class: 'btn btn-primary', type: append_button[:type] || 'button', 'on-click-get' => append_button[:href] do text append_button[:text] end end end end else mab { input options } end end
errors?()
click to toggle source
# File lib/conjoin/form_builder.rb, line 328 def errors? data.errors end
id()
click to toggle source
# File lib/conjoin/form_builder.rb, line 317 def id data.name.gsub(/[^a-z0-9]/, '_').gsub(/__/, '_').gsub(/_$/, '') end
nested_name()
click to toggle source
# File lib/conjoin/form_builder.rb, line 321 def nested_name # create field names that map to the correct models data.names.each_with_index.map do |field, i| i != 0 ? "[#{field}]" : field end.join end
render()
click to toggle source
# File lib/conjoin/form_builder.rb, line 332 def render if options[:type] == :hidden \ or (options.key?(:wrapper) and options[:wrapper] == false) options[:class] = options[:class].gsub(/form-control/, '') end display end