Class: Katalyst::Tables::Selectable::FormComponent

Inherits:
ViewComponent::Base
  • Object
show all
Includes:
HtmlAttributes, Identifiable::Defaults
Defined in:
app/components/katalyst/tables/selectable/form_component.rb

Overview

:nodoc:

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Identifiable::Defaults

#default_table_id

Constructor Details

#initialize(collection:, id: nil, primary_key: :id) ⇒ FormComponent

Returns a new instance of FormComponent.

Parameters:

  • collection (Katalyst::Tables::Collection::Core)

    the collection to render

  • id (String) (defaults to: nil)

    the id of the form element (defaults to <resources>_selection_form)

  • primary_key (String) (defaults to: :id)

    the primary key of the record in the collection (defaults to :id)



15
16
17
18
19
20
21
22
23
# File 'app/components/katalyst/tables/selectable/form_component.rb', line 15

def initialize(collection:,
               id: nil,
               primary_key: :id)
  super()

  @collection  = collection
  @id          = id || Selectable.default_form_id(collection)
  @primary_key = primary_key
end

Instance Attribute Details

#idObject (readonly)

Returns the value of attribute id.



10
11
12
# File 'app/components/katalyst/tables/selectable/form_component.rb', line 10

def id
  @id
end

#primary_keyObject (readonly)

Returns the value of attribute primary_key.



10
11
12
# File 'app/components/katalyst/tables/selectable/form_component.rb', line 10

def primary_key
  @primary_key
end

Instance Method Details

#inspectObject



25
26
27
# File 'app/components/katalyst/tables/selectable/form_component.rb', line 25

def inspect
  "#<#{self.class.name} id: #{id.inspect}, primary_key: #{primary_key.inspect}>"
end