fix: pass actor to CustomFieldLive.FormComponent for save
IndexComponent now passes actor to FormComponent; FormComponent uses assigns[:actor] instead of current_actor(socket). Add test that submits new custom field form on settings page.
This commit is contained in:
parent
1d17c4f2dd
commit
9a7622ebed
3 changed files with 44 additions and 1 deletions
|
|
@ -91,7 +91,8 @@ defmodule MvWeb.CustomFieldLive.FormComponent do
|
|||
|
||||
@impl true
|
||||
def handle_event("save", %{"custom_field" => custom_field_params}, socket) do
|
||||
actor = MvWeb.LiveHelpers.current_actor(socket)
|
||||
# Actor must be passed from parent (IndexComponent); component socket has no current_user
|
||||
actor = socket.assigns[:actor]
|
||||
|
||||
case MvWeb.LiveHelpers.submit_form(socket.assigns.form, custom_field_params, actor) do
|
||||
{:ok, custom_field} ->
|
||||
|
|
|
|||
|
|
@ -38,6 +38,7 @@ defmodule MvWeb.CustomFieldLive.IndexComponent do
|
|||
<.live_component
|
||||
module={MvWeb.CustomFieldLive.FormComponent}
|
||||
id={@form_id}
|
||||
actor={@actor}
|
||||
custom_field={@editing_custom_field}
|
||||
on_save={
|
||||
fn custom_field, action -> send(self(), {:custom_field_saved, custom_field, action}) end
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue