Class: Maquina::Sessions::Form

Inherits:
Phlex::HTML
  • Object
show all
Includes:
ApplicationView, Phlex::Rails::Helpers::FormWith
Defined in:
app/views/maquina/sessions/form.rb

Instance Method Summary collapse

Methods included from ApplicationView

#attribute_human_name, #button_to, #image_tag, #link_to, #model_human_name, #svg_icon

Constructor Details

#initialize(resource) ⇒ Form

Returns a new instance of Form.



9
10
11
# File 'app/views/maquina/sessions/form.rb', line 9

def initialize(resource)
  @resource = resource
end

Instance Method Details

#view_templateObject



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'app/views/maquina/sessions/form.rb', line 13

def view_template
  div(class: "mt-8 sm:mx-auto sm:w-full sm:max-w-md") do
    div(class: "bg-white py-8 px-4 shadow sm:rounded-lg sm:px-10") do
      form_with(url: sessions_path, method: :post, class: "space-y-6") do |form|
        div do
          form.label t("form.sessions.email"), for: :email, class: "block label"
          div(class: "mt-1") do
            form.text_field :email, value: @resource.email, type: :email, required: true, class: "w-full block input", **field_attributes(:email)
          end
        end
        div do
          form.label t("form.sessions.password"), for: :password, class: "block label"
          div(class: "mt-1") do
            form.password_field :password, value: @resource.password, required: true, class: "w-full block input", **field_attributes(:password)
          end
        end
        div(class: "flex items-center justify-between") do
          div do
          end
          div(class: "text-sm") do
            a(href: "#", class: "link") { t("form.sessions.forgot_password") }
          end
        end
        div do
          form.submit t("form.sessions.submit"), class: "flex w-full justify-center button button-accented"
        end
      end
    end
  end
end