class TemplateForm::FormBuilder
Attributes
form_type[R]
Public Class Methods
new(*)
click to toggle source
Calls superclass method
# File lib/template_form/form_builder.rb, line 18 def initialize(*) super # Do not remove `:form_type` from `options`. It has to stay so # when `fields_for()` instantiates a new form builder for each # associated record, the second and subsequent ones have the # correct form type. @form_type = options[:form_type] || TemplateForm.form_type end
Public Instance Methods
input(attribute_name, options = {})
click to toggle source
# File lib/template_form/form_builder.rb, line 27 def input(attribute_name, options = {}) attribute_type = options.delete(:as) || (@object.respond_to?(:type_for_attribute) && @object.type_for_attribute(attribute_name).type) || :string options[:type] ||= 'password' if attribute_name.match(/password/) input_for(attribute_type).new(self, attribute_name, options).render end
Private Instance Methods
input_for(attribute_type)
click to toggle source
# File lib/template_form/form_builder.rb, line 45 def input_for(attribute_type) case attribute_type when :string then TextInput when :text then TextareaInput when :date then DateInput when :boolean then CheckboxInput when :file then FileInput when :select then SelectInput when :grouped_select then GroupedSelectInput end end