35 lines
1.1 KiB
Elixir
35 lines
1.1 KiB
Elixir
defmodule WildWeb.BookThoughts do
|
|
use WildWeb, :live_view
|
|
|
|
def render(assigns) do
|
|
~H"""
|
|
<div class="text-center">
|
|
<.header>
|
|
Let the forest hear your thoughts on this book
|
|
<:subtitle>The wind will carry your howl</:subtitle>
|
|
</.header>
|
|
</div>
|
|
<.simple_form for={@form} phx-changed="validate" phx-submit="save">
|
|
<.input field={@form[:book_title]} type="text" label="Book Title" required />
|
|
<.input field={@form[:author]} type="text" label="Author" required />
|
|
<.rating_stars />
|
|
<.input field={@form[:book_review]} type="textarea" label="Your Wild Thoughts" required />
|
|
<.input field={@form[:start_date]} type="date" label="Reading Start Date" required />
|
|
<.input field={@form[:finish_date]} type="date" label="Reading Finish Date" required />
|
|
</.simple_form>
|
|
"""
|
|
end
|
|
|
|
def mount(_params, _session, socket) do
|
|
form =
|
|
to_form(%{
|
|
"book_title" => "",
|
|
"author" => "",
|
|
"book_review" => "",
|
|
"start_date" => "",
|
|
"finish_date" => ""
|
|
})
|
|
|
|
{:ok, assign(socket, form: form), temporary_assigns: [form: form]}
|
|
end
|
|
end
|