Hi all,
According to the documentation Live components can accept blocks, however, I’m having trouble with it. Here is what I’m trying to do:
# component:
def render(assigns) do
~L"""
<div>
<%= render_block(@inner_block) %>
</div>
"""
end
# live view:
<%= form_for @changeset, Routes.user_registration_path(@socket, :create), fn f -> %>
<%= live_component(@socket, FormsEntryComponent) do %>
<p>Foo</p>
<% end %>
...
<% end %>
But I’m getting the following error: cannot convert component SleeprescueWeb.FormsEntryComponent with id nil to HTML.
. I’ve also tried passing id into the live component in which case the error changes to cannot convert ... with id "foo" to HTML.
. Interestingly, in the logs I’ve also been getting a warning warning: variable "assigns" is unused
when I try to use this component, so something is clearly amiss.
Importantly, I’d like to note that this works outside a form_for
block but fails inside it. Any suggestions for how to deal with this?
Would anyone happen to know how I could get this working?
Many thanks!