Class: RubyUI::DataTableForm

Inherits:
Base
  • Object
show all
Defined in:
lib/ruby_ui/data_table/data_table_form.rb

Constant Summary

Constants inherited from Base

Base::TAILWIND_MERGER

Instance Attribute Summary

Attributes inherited from Base

#attrs

Instance Method Summary collapse

Constructor Details

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

Returns a new instance of DataTableForm.



5
6
7
8
9
10
# File 'lib/ruby_ui/data_table/data_table_form.rb', line 5

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

Instance Method Details

#view_template(&block) ⇒ Object



12
13
14
15
16
17
18
19
# File 'lib/ruby_ui/data_table/data_table_form.rb', line 12

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