Class: Models::Form

Inherits:
Components::Base
  • Object
show all
Includes:
Phlex::Rails::Helpers::FormWith
Defined in:
app/components/databasium/models/form.rb

Instance Method Summary collapse

Constructor Details

#initialize(attributes: nil, model: nil, models: nil) ⇒ Form

Returns a new instance of Form.



8
9
10
11
12
# File 'app/components/databasium/models/form.rb', line 8

def initialize(attributes: nil, model: nil, models: nil)
  @attributes = attributes
  @model = model
  @models = models
end

Instance Method Details

#view_templateObject



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'app/components/databasium/models/form.rb', line 14

def view_template
  form_with(
    url: databasium.models_path,
    method: :post,
    scope: :model,
    html: {
      id: "model_form"
    }
  ) do |form|
    render_model_name(form)
    render_form
    render_attributes_container
    render_relations_container
    render_unknown
    form.submit "Create preview for model",
                class: "bg-accent shadow-accent rounded-xl p-1 p-2 mt-2 w-full text-center"
  end
end