Class: Formulaic::Form

Inherits:
Object
  • Object
show all
Defined in:
lib/formulaic/form.rb

Defined Under Namespace

Classes: InvalidAttributeTypeError

Constant Summary collapse

ATTRIBUTE_INPUT_MAP =
{
  ActiveSupport::TimeWithZone => Formulaic::Inputs::DateInput,
  Date => Formulaic::Inputs::DateInput,
  DateTime => Formulaic::Inputs::DateTimeInput,
  Array => Formulaic::Inputs::ArrayInput,
  String => Formulaic::Inputs::StringInput,
  Symbol => Formulaic::Inputs::StringInput,
  1.class => Formulaic::Inputs::StringInput,
  Float => Formulaic::Inputs::StringInput,
  TrueClass => Formulaic::Inputs::BooleanInput,
  FalseClass => Formulaic::Inputs::BooleanInput,
  File => Formulaic::Inputs::FileInput,
  Rack::Multipart::UploadedFile => Formulaic::Inputs::FileInput
}.freeze

Instance Method Summary collapse

Constructor Details

#initialize(model_name, action, attributes) ⇒ Form

Returns a new instance of Form.



21
22
23
24
# File 'lib/formulaic/form.rb', line 21

def initialize(model_name, action, attributes)
  @action = action
  @inputs = build_inputs(model_name, attributes)
end

Instance Method Details

#fillObject



26
27
28
# File 'lib/formulaic/form.rb', line 26

def fill
  @inputs.each { |input| input.fill }
end