I’m attempting to create a nested form with duplicate inputs for two separate ticket holders. I’m using the <.simple_form> in LiveView, and everything I’ve seen is using different syntax (i.e. <% as opposed to <.)
I have this form working:
<.simple_form :let={f} for={%{tickets: []}}>
<.input
field={f[:text]}
type="text" label="Enter text:"
autocomplete="text"
placeholder="Enter text" />
<.input
field={f[:option_id]}
type="select"
label="Choose your option:"
options={Enum.map(options, fn option -> {option.name, option.id} end)}
/>
<.input
field={f[:date]}
type="date"
label="Choose a date:"
/>
<.input
field={f[:time]}
type="time"
label="Choose a time:"
/>
<div class="flex gap-2">
<div class="w-2/3">
<.input
field={f[:weight]}
type="number"
label="Weight"
min="0"
/>
</div>
<div class="w-1/3 mt-1">
<.input
field={f[:weight_unit]}
type="select"
label="Unit"
options={Enum.map(weight_units, fn weight -> weight.unit end)}
/>
</div>
</div>
<:actions>
<.button button_type="booking">Continue</.button>
</:actions>
</.simple_form>
however when I try to add this at the top of the form to test (from the Phoenix docs):
<.inputs_for :let={fp} field={f[:tickets]}>
<.input field={fp[:name]} type="text" />
</.inputs_for>
I receive this error:
construction of binary failed: segment 1 of type 'binary': expected a binary but got: nil
with this stack trace:
id = to_string(id || form.id <> "_#{field}")
Any idea on how to create a duplicate nested form of the current simple form with a nested inputs_for? Thanks!