Class: Keystone::Ui::FormComponent

Inherits:
ViewComponent::Base
  • Object
show all
Defined in:
app/components/keystone/ui/form_component.rb

Constant Summary collapse

FORM_CLASSES =
"space-y-6"

Instance Method Summary collapse

Constructor Details

#initialize(action:, method: :post, multipart: false, data: nil) ⇒ FormComponent

Returns a new instance of FormComponent.



8
9
10
11
12
13
# File 'app/components/keystone/ui/form_component.rb', line 8

def initialize(action:, method: :post, multipart: false, data: nil)
  @action = action
  @method = method.to_sym
  @multipart = multipart
  @data = data
end

Instance Method Details

#form_optionsObject



15
16
17
18
19
20
21
22
23
24
# File 'app/components/keystone/ui/form_component.rb', line 15

def form_options
  options = {
    url: @action,
    method: @method,
    class: FORM_CLASSES,
    multipart: @multipart
  }
  options[:data] = @data if @data
  options
end