Class: PhlexKit::DataTableForm

Inherits:
BaseComponent show all
Defined in:
app/components/phlex_kit/data_table/data_table_form.rb

Overview

POST form wrapping the table for bulk actions (row checkboxes submit through it). Includes the Rails CSRF token when a view context is around. See data_table.rb.

Instance Method Summary collapse

Methods inherited from BaseComponent

#on

Constructor Details

#initialize(action: "", method: "post", id: nil, **attrs) ⇒ DataTableForm

Returns a new instance of DataTableForm.



6
7
8
9
10
11
# File 'app/components/phlex_kit/data_table/data_table_form.rb', line 6

def initialize(action: "", method: "post", id: nil, **attrs)
  @action = action
  @method = method
  @id = id
  @attrs = attrs
end

Instance Method Details

#view_template(&block) ⇒ Object



13
14
15
16
17
18
19
20
# File 'app/components/phlex_kit/data_table/data_table_form.rb', line 13

def view_template(&block)
  form_attrs = { action: @action, method: @method }
  form_attrs[:id] = @id if @id
  form(**mix(form_attrs, @attrs)) do
    input(type: :hidden, name: "authenticity_token", value: csrf_token)
    yield if block
  end
end