Class: Super::Form

Inherits:
Object
  • Object
show all
Includes:
Schema::Common
Defined in:
lib/super/form.rb,
lib/super/form/builder.rb,
lib/super/form/guesser.rb,
lib/super/form/schema_types.rb,
lib/super/form/inline_errors.rb,
lib/super/form/strong_params.rb

Overview

This schema type is used on your +#edit+ and +#new+ forms

class MembersController::Controls
  # ...

  def new_schema
    Super::Form.new do |fields, type|
      fields[:name] = type.string
      fields[:rank] = type.select
      fields[:position] = type.string
      fields[:ship_id] = type.select(
        collection: Ship.all.map { |s| ["#{s.name} (Ship ##{s.id})", s.id] },
      )
    end
  end

  # ...
end

Defined Under Namespace

Modules: InlineErrors Classes: Builder, Guesser, SchemaTypes, StrongParams

Instance Method Summary collapse

Methods included from Schema::Common

#each_attribute, #each_attribute_name

Constructor Details

#initialize {|@fields, @schema_types| ... } ⇒ Form

Returns a new instance of Form.

Yields:

  • (@fields, @schema_types)


27
28
29
30
31
# File 'lib/super/form.rb', line 27

def initialize
  @fields = Schema::Fields.new
  @schema_types = SchemaTypes.new(fields: @fields)
  yield(@fields, @schema_types)
end

Instance Method Details

#to_partial_pathObject



33
34
35
# File 'lib/super/form.rb', line 33

def to_partial_path
  "form"
end