diff --git a/lib/chat_app_live_web/live/chat_form_live.ex b/lib/chat_app_live_web/live/chat_form_live.ex
index f7350af..c4e4b86 100644
--- a/lib/chat_app_live_web/live/chat_form_live.ex
+++ b/lib/chat_app_live_web/live/chat_form_live.ex
@@ -9,6 +9,13 @@ defmodule ChatAppLiveWeb.ChatFormLive do
{:ok, assign(socket, form: to_form(Messages.change_message(%Message{})), messages: messages)}
end
+ defp get_message!(message_id) do
+ case Repo.get(Message, message_id) do
+ nil -> {:error, "Message not found"}
+ message -> {:ok, message}
+ end
+ end
+
def handle_event("save", %{"message" => message_params}, socket) do
case Messages.create_message(message_params) do
{:ok, _message} ->
@@ -77,6 +84,7 @@ defmodule ChatAppLiveWeb.ChatFormLive do
Edit
@@ -106,6 +114,25 @@ defmodule ChatAppLiveWeb.ChatFormLive do
<% end %>
+
+
+ Edit Message
+ <.form for={@form} phx-submit="save">
+
+ <.input type="textarea" field={@form[:content]} />
+
+
+
+
+
+
+
+
"""
end
end