Fetching values in nested forms

I have a nested form for edit court. A court has many booking slots

<%= inputs_for f, :slots, fn p -> %>
<%= label p, :hour, class: "control-label" %>
<%= text_input p, :hour, class: "form-control" %>
<%= error_tag p, :hour %>
<% end %>

What i want is adding a if condition like that.

<%= if slot.weekday == 1 do%>

But i cant fetch values in :slots. How can i do that ?

I solved, values are in data key so code is like that

<%= if p.data.weekday == 1 do%>

1 Like

You can also do:

<%= if input_value(p, :weekday) == 1 %>

That should then work even if the structure of the input form data may change.