itisfilipe
I am trying to use two nested inputs_for with no success. Essentially, I have this (abbreviated for simplicity):
# CalendarApp.Calendars.Calendar
schema "calendars" do
...
# In the migration I have "add :working_hours, :map"
embeds_many :working_hours, WorkingHour, on_replace: :delete
end
# CalendarApp.Calendars.WorkingHour
embedded_schema do
...
embeds_many :time_intervals, TimeInterval, on_replace: :delete
end
# CalendarApp.Calendars.TimeInterval
embedded_schema do
...
# no more embeds
end
My object
%CalendarApp.Calendars.Calendar{
__meta__: #Ecto.Schema.Metadata<:loaded, "calendars">,
id: 1,
working_hours: [
%CalendarApp.Calendars.WorkingHour{
id: "c8140693-be33-4f50-a087-653ce92fa3be",
weekday: :Sunday,
enabled: false,
time_intervals: [
%CalendarApp.Calendars.TimeInterval{
id: "0d31837a-d295-4d7b-984f-edfe18858f70",
start_time: ~T[08:00:00],
end_time: ~T[12:00:00]
},
%CalendarApp.Calendars.TimeInterval{
id: "e11b03a4-75be-4067-b477-733ebea6b31c",
start_time: ~T[13:00:00],
end_time: ~T[18:00:00]
}
]
},
%CalendarApp.Calendars.WorkingHour{
id: "a5a70b7e-577a-42b0-a2f7-4d396c3cd3ad",
weekday: :Monday,
enabled: true,
time_intervals: [
%CalendarApp.Calendars.TimeInterval{
id: "865aeea2-d234-47c1-aa1d-b8655c2909f7",
start_time: ~T[08:00:00],
end_time: ~T[12:00:00]
},
%CalendarApp.Calendars.TimeInterval{
id: "f80e3863-b801-4964-8c71-f7fca7d567ba",
start_time: ~T[13:00:00],
end_time: ~T[18:00:00]
}
]
},
...
]
}
how I am trying to present this data
<%= for whf <- inputs_for(f, :working_hours) do %>
<li class="pb-4 flex items-center justify-between">
<%= hidden_inputs_for(whf) %>
<%= label whf, :weekday, class: "text-base font-medium text-gray-900" do %>
<%= whf.data.weekday %>
<% end %>
<%= for intf <- inputs_for(whf, :time_intervals) do %>
<%= hidden_inputs_for(intf) %>
<% time_input intf, :start_time %>
<% time_input intf, :end_time %>
<% end %>
<%= error_tag whf, :weekday %>
</li>
<% end %>
Just the labels and the hidden fields are being rendered
<ul role="list">
<li class="pb-4 flex items-center justify-between">
<input id="calendar_working_hours_0_id" name="calendar[working_hours][0][id]" type="hidden" value="c8140693-be33-4f50-a087-653ce92fa3be">
<label class="text-base font-medium text-gray-900" for="calendar_working_hours_0_weekday">
Sunday
</label>
<input id="calendar_working_hours_0_time_intervals_0_id" name="calendar[working_hours][0][time_intervals][0][id]" type="hidden" value="0d31837a-d295-4d7b-984f-edfe18858f70">
<input id="calendar_working_hours_0_time_intervals_1_id" name="calendar[working_hours][0][time_intervals][1][id]" type="hidden" value="e11b03a4-75be-4067-b477-733ebea6b31c">
</li>
<li class="pb-4 flex items-center justify-between">
<input id="calendar_working_hours_1_id" name="calendar[working_hours][1][id]" type="hidden" value="a5a70b7e-577a-42b0-a2f7-4d396c3cd3ad">
<label class="text-base font-medium text-gray-900" for="calendar_working_hours_1_weekday">
Monday
</label>
<input id="calendar_working_hours_1_time_intervals_0_id" name="calendar[working_hours][1][time_intervals][0][id]" type="hidden" value="865aeea2-d234-47c1-aa1d-b8655c2909f7">
<input id="calendar_working_hours_1_time_intervals_1_id" name="calendar[working_hours][1][time_intervals][1][id]" type="hidden" value="f80e3863-b801-4964-8c71-f7fca7d567ba">
</li>
...
</ul>
I’ve tried many different fields and structures for this form but without success. Does anyone know if this is even possible?
Trending in Questions
Hey guys,
I’ve got a huge CSV ( around 10 GB ) that needs to be processed hourly
Do you guys have any suggestions what is the best prac...
New
Hello!
Could someone please give me a help/sample code, how to delete a file from s3 using waffle/waffle_ecto from Phoenix app.
I creat...
New
I have what I’ve heard referred to as a “lookup table” in my database. This is a way of assigning codes to common values. One common lo...
New
Hello,
I’m developing a online persistent chat system (what’s app) like using elixir/dynamodb/aws for a mobile app(flutter).
The diffic...
New
What approach to take when sending live updates to “random” users Hi! I have a question, I have a little chat app, and when I create a DM...
New
Anyone here using Honeybadger?
My Honeybadger account is being overwhelmed with noise from some bots. Seeing a lot of
Bandit.HTTPError...
New
I’m seeing that a list inside a Kino.DataTable will be interpreted as a charlist, even if the Kino.configure() is set to charlists: :as_l...
New
Other Trending Topics
Hobbes is a low-level distributed database for the Elixir programming language.
Hobbes provides a simple, safe, and scalable storage lay...
New
ExRatatui lets you cook up rich terminal UIs in Elixir, powered by Rust’s ratatui via Rustler NIFs. Build interactive terminal applicatio...
New
Hello everyone. After busy few months I am happy to announce v0.1.0 of Emerge & Solve.
They are GUI (Emerge) and State management (S...
New
Corex is an accessible, unstyled UI component library for Phoenix that integrates Zag.js state machines using Vanilla JavaScript and Live...
New
There are three potential reasons for members of this forum to have a look at https://vutuv.de
You are tired or annoyed of LinkedIn.
Yo...
New
Aludel - LLM Evaluation Workbench
Aludel is an embeddable Phoenix LiveView dashboard for evaluating and comparing LLM prompts across mult...
New
Latest Phoenix Threads
Latest on Elixir Forum
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #elixirconf
- #channels
- #exunit
- #discussion
- #code-sync
- #javascript
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixir-ls
- #blog-post
- #ai
- #elixirconf-us
- #phoenix_html
- #iex
- #graphql
- #genstage
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #hex
- #security
- #metaprogramming












Showing Posts 1 to 2- Show Best Posts
- Show All (oldest first)
- Show All (newest first)
woylie
This should be
itisfilipe
Oh, I can’t believe I spent the last two days trying to fix it and it was a silly typo
. Thank you for the help, it worked!