Hi,
I’m building a LiveView .simple_form, but I’m not sure how to stitch everything together correctly.
I can see in the logs that every field in the form is passed to the “validate” event, but not to the “save” event.
I don’t understand why.
I also see that some of the “validate” events have a target “summary” and some have “matrix”. I would like all these fields to be grouped into the same namespace.
From the logs
[debug] HANDLE EVENT "validate" in EasyWeb.WizardLive.Summary.Edit
Component: EasyWeb.WizardLive.Form
Parameters: %{"_target" => ["summary", "nr_of_pip_sources"],
"include_main_source" => "true",
"summary" => %{"coming_from" => "solution_information",
"id" => "10", "nr_of_pip_sources" => "22"}}
[debug] HANDLE EVENT "validate" in EasyWeb.WizardLive.Summary.Edit
Component: EasyWeb.WizardLive.Form
Parameters: %{"_target" => ["matrix"], "matrix" => "modular",
"summary" => %{"coming_from" => "solution_information",
"id" => "10", "nr_of_pip_sources" => "22"}}
[debug] HANDLE EVENT "save" in EasyWeb.WizardLive.Summary.Edit
Component: EasyWeb.WizardLive.Form
Parameters: %{"matrix" => "modular",
"summary" => %{"coming_from" => "solution_information",
"id" => "10", "nr_of_pip_sources" => "22"}}
form.html.heex
<div id="wizard">
<.simple_form
for={@form}
phx-change="validate"
phx-submit="save"
id={@id}
class="w-full"
phx-target={@myself}
>
<%= if @step == "solution_information" and @sub_step == "details" do %>
<h2 class=" mb-2 text-3lg font-extrabold tracking-tight text-gray-900 dark:text-white">
Solution information X
</h2>
<.input field={@form[:id]} type="hidden" value={@summary_id} />
<.input field={@form[:coming_from]} type="hidden" value="solution_information" />
Do you need the system to include a main source? <br />
<.input
name="include_main_source"
label="Yes"
field={@form[:include_main_source]}
id="yes"
type="radio"
value="true"
/>
<.input
id="nr_of_pip_sources"
field={@form[:nr_of_pip_sources]}
label="Number of sim PIP sources"
type="number"
phx-debounce="blur"
phx-feedback-for="name"
/>
<strong>What type of Matrix do you want to use?</strong>
<.input
id="fixed_standalone"
field={@form[:matrix]}
label="Fixed standalone"
type="radio"
name="matrix"
value="fixed_standalone"
/>
<.input
label="Modular"
id="modular"
type="radio"
name="matrix"
field={@form[:matrix]}
value="modular"
/>
<.input
label="AV Over IP"
id="av_over_ip"
type="radio"
name="matrix"
field={@form[:matrix]}
value="av_over_ip"
/>
<% end %>
<:actions>
<div class="mt-2 flex items-center justify-between gap-6">
<.button phx-disable-with="Saving..." >
Save
</.button>
</div>
</:actions>
</.simple_form>
</div>