Class: Maquina::Application::Form
- Inherits:
-
Phlex::HTML
- Object
- Phlex::HTML
- Maquina::Application::Form
- Includes:
- Maquina::ApplicationView, Phlex::Rails::Helpers::FormWith
- Defined in:
- app/views/maquina/application/form.rb
Instance Method Summary collapse
-
#initialize(resource:, modal: false) ⇒ Form
constructor
A new instance of Form.
- #view_template ⇒ Object
Methods included from Maquina::ApplicationView
#attribute_human_name, #button_to, #image_tag, #link_to, #model_human_name, #svg_icon
Constructor Details
#initialize(resource:, modal: false) ⇒ Form
Returns a new instance of Form.
11 12 13 14 |
# File 'app/views/maquina/application/form.rb', line 11 def initialize(resource:, modal: false) @resource = resource @modal = modal end |
Instance Method Details
#view_template ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'app/views/maquina/application/form.rb', line 16 def view_template form_with(model: @resource, url: if @resource.persisted? resource_path(@resource) else (submit_path.present? ? submit_path : collection_path) end, data: {turbo_frame: :_top}) do |form| div(class: "space-y-8 divide-y divide-gray-200") do div do form_header_template div(class: "mt-6 grid grid-cols-1 gap-y-6 gap-x-4 sm:grid-cols-6") do attributes_template(form) end end div(class: "pt-5") do div(class: "flex justify-end") do link_to t("helpers.cancel"), collection_path, class: "button", data: @modal ? {action: "modal#close"} : {turbo_frame: :_top} form.submit class: "ml-3 button button-accented" end end end end end |