How can I send a submit message to a livecomponent form from a liveview?

I have a modal that is managed inside of the parent liveview. The modal contains a form component. Since the buttons on the modal are at the top-level, I can’t submit the form directly.

How can I send a message to the form component that’s in the modal in order to submit it?

<%= case @modal_action do %>
  # ..........
  <% :record_decision -> %>
      title="Record decision"
      subtitle="Add a new decision to record the associated reasoning and discussion."
      confirm_text="Create Decision">
      <.live_component module={Decisions.Form} id="decision-form" account={@current_account} />
  <% _ -> %>
    <div class="hidden"></div>
<% end %>

I believe you can use the JS.push to make sure the event is handled by your LiveComponent.

There’s also phx-target.

Here’s a write up by that explains further.

Thanks, I think I’ll do it with with JS module. Makes a lot of sense after reading that article cheers.