mogadget
Nested form using inputs_for is not rendering
I have a relationship User has_one Profile. In my User
defmodule Cal.Accounts.User do
actions do
defaults [:read]
create :create_user_with_profile do
argument :profile, :map do
allow_nil? false
end
change manage_relationship(:profile, type: :create)
end
action
relationship do
has_one :profile, Cal.Accounts.Profile do
destination_attribute :user_profile_id
end
end
...
end
In my form liveview
def mount(_params, _session, socket) do
form = Cal.Accounts.form_to_create_user_with_profile()
socket =
socket
|> assign(:form, to_form(form))
|> assign(:page_title, "New User with Profile")
{:ok, socket}
end
def render(assigns) do
...
<h4>User</h4>
<.input field={form[:email]} label="Email" />
<.input field={form[:user_name]} label="Name" />
<.input field={form[:timezone]} label="Timezone" />
<h4>User Profile</h4>
<.inputs_for :let={form_profile} field={@form[:profile]}>
<.input field={form_profile[:title]} label="Title" />
<.input field={form_profile[:location]} label="Location" />
</.inputs_for>
end
The form renders the Email, Name and Timezone but the fields for profile Title and Location are not
First Post!
cmo
Throw a few inspects in there to see what data you’re getting in render. IIRC <prev>{inspect(@form[:profile], pretty: true)}</pre>.
0
Last Post!
cmo
Popular in Questions
What is the proper way to load a module from a file in to IEX?
In the python world, doing something like this pretty standard:
from ....
New
I believe there are people here who are dealing with CSV files import on the daily basis, and since Excel is a really popular tool there ...
New
What is the difference between System.get_env and Application.get_env? For example, what are best practices to use one versus another.
New
Hello!
Sorry for this astonishing simple question, but I’m really stuck. I try to set up the intellij-elixir plugin, but I don’t know ho...
New
What’s the safe way to decode a JSON string into a struct? I want to avoid calling String.to_atom. Jason.decode can give me a map with st...
New
What is the idiomatic way of matching for not nil in Elixir?
E.g.,
First way:
defp halt_if_not_signed_in(conn, signed_in_account) when...
New
I am using the Starship cross-shell prompt – it seems pretty nice, but I get some errors:
[WARN] - (starship::utils): Executing command ...
New
Other popular topics
Hello, can anybody help here..? I have a list of players and I what to delete an element, but every for loop the list is reverting to ori...
New
Hi folks,
Few months ago I have announced the proof-of-concept of the library to manipulate the browsers DOM objects directly from Elixi...
New
Hello!
Sorry for this astonishing simple question, but I’m really stuck. I try to set up the intellij-elixir plugin, but I don’t know ho...
New
I wrote this comment on r/haskell, and it’s not popular there. :wink: But I think I’m on to something…
Haskell reminds me of Java, and e...
New
Phoenix 1.4.0 released
Phoenix 1.4 is out! This release ships with exciting new features, most notably
with HTTP2 support, improved deve...
New
Hello all!
I am typing this post from my new MacBook Pro with the M1 chip. I’m loving it so far, and will probably use it as my daily dr...
New
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
- #channels
- #elixirconf
- #exunit
- #discussion
- #code-sync
- #javascript
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixir-ls
- #phoenix_html
- #iex
- #blog-post
- #graphql
- #genstage
- #ai
- #websockets
- #supervisor
- #elixirconf-us
- #advent-of-code
- #distillery
- #processes
- #forms
- #api
- #metaprogramming
- #hex
- #security









