mogadget

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

cmo

Throw a few inspects in there to see what data you’re getting in render. IIRC <prev>{inspect(@form[:profile], pretty: true)}</pre>.

Where Next?

Popular in Questions Top

dotdotdotPaul
Okay, I'm having a heck of a time trying to figure out how to best handle the validation of belongs_to associations in Ecto. I'm sure I'...
New
openscript
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
Werner
Hi, I’m using Ubuntu 18.04 and after updating to OTP-24.0 yesterday i have this warning when I run “mix local.hex”: 14:57:30.512 [warn] ...
New
lk-geimfari
What is most correct way to open, read and parse JSON file with poison? For example if we have example.json file in root of some projec...
New
Phillipp
Hey, I have a NanoPi-M3 and try to install Elixir on their Ubuntu image. I followed the Raspberry Pi installation instructions from the ...
New
makeitrein
Hey all, just started picking up Elixir last week and am writing a scraper as a learning project. Baby step #1 is extracting the number ...
New
gonzofish
I’m currently trying to understand how to join three tables using Ecto. All the examples I’ve seen use 2, so maybe I’m just missing somet...
New
beno
I will often find my self writing things similar to: case some_value do nil -&gt; something() "" -&gt; something() _ -&gt; someth...
New
Mooodi
Given a string, how can I get access to its character by index? Enum.at("my_string", 2) doesn't work. Or rather, not char, but a substr...
New
romenigld
I am trying to run a deploy with docker and I successfully runned with this command: docker build -t romenigld/blog-prod . but when I t...
New

Other popular topics Top

JDanielMartinez
Hi! May someone helps me, please! I have two apps into an umbrella project: the first one is Database, which manages queries, and the se...
New
William
I would like to know that is there any online source for learning Phoenix Framework for building E-Commerce Store? Any advantage on build...
New
yawaramin
In the Dialyzer docs ( http://erlang.org/doc/man/dialyzer.html#requesting-or-suppressing-warnings-in-source-files ), there is a way to tu...
New
JorisKok
I have a server on AWS, and was running a load test using artillery. When looking at the Phoenix dashboard I see the Ports going to 100% ...
New
sergio_101
I am VERY much an elixir newbie. I have taken one elixir course and one phoenix course on Udemy. During that course, I saw the instructor...
New
grych
Hi folks, Few months ago I have announced the proof-of-concept of the library to manipulate the browsers DOM objects directly from Elixi...
639 49522 488
New
fireproofsocks
Forgive me if this is obvious, but how does one delete a database record WITHOUT selecting it first? https://hexdocs.pm/ecto/Ecto.Repo.h...
New
Patoshizzle
After calling mix ecto.create I get this error: 17:00:32.162 [error] GenServer #PID&lt;0.412.0&gt; terminating ** (Postgrex.Error) FATAL...
New
Nvim
Elixir appears to be a superior language to Python. I don’t see any advantage of Python over Elixir. Are there any?
New
siddhant3030
Hi, I have to write a raw query for one of my project. But till now I have used ecto queries and don’t have much experience writing raw ...
New

We're in Beta

About us Mission Statement