CarlosIribar

CarlosIribar

Name not found in input core component

Hi! I’m new in Phoenix and Liveview. I’m trying to create a form using a changeset but I don’t know why the input core component can’t find the name, id, value, etc key.

Here is my form:

<.simple_form :let={f} for={@changeset |> dbg()} id="promo-form" phx-change="validate" phx-submit="save">
    <.input field={{f, :first_name} |> dbg()} type="text" label="First Name" />
    <.input field={{f, :email}} type="email" label="Email" phx-debounce="blur" />
    <:actions>
      <.button phx-disable-with="Sending...">Send Promo</.button>
    </:actions>
  </.simple_form>

And here is the error:
key :name not found in: %{changed: nil, given: %{changed: nil, field: {%Phoenix.HTML.Form{source: #Ecto.Changeset<action: nil, changes: %{}, errors: [first_name: {“can’t be blank”, [validation: :required]}, email: {“can’t be blank”, [validation: :required]}], data: #Pento.Promo.Recipient<>, valid?: false>, impl: Phoenix.HTML.FormData.Ecto.Changeset, id: “promo-form”, name: “recipient”, data: %Pento.Promo.Recipient{email: nil, first_name: nil}, hidden: [], params: %{}, errors: [], options: [method: “post”, id: “promo-form”, multipart: false, “phx-change”: “validate”, “phx-submit”: “save”], index: nil, action: nil}, :first_name}, label: “First Name”, type: “text”}, errors: [], field: {%Phoenix.HTML.Form{source: #Ecto.Changeset<action: nil, changes: %{}, errors: [first_name: {“can’t be blank”, [validation: :required]}, email: {“can’t be blank”, [validation: :required]}], data: #Pento.Promo.Recipient<>, valid?: false>, impl: Phoenix.HTML.FormData.Ecto.Changeset, id: “promo-form”, name: “recipient”, data: %Pento.Promo.Recipient{email: nil, first_name: nil}, hidden: [], params: %{}, errors: [], options: [method: “post”, id: “promo-form”, multipart: false, “phx-change”: “validate”, “phx-submit”: “save”], index: nil, action: nil}, :first_name}, id: nil, inner_block: [], label: “First Name”, multiple: false, prompt: nil, rest: %{}, type: “text”}

The core component:

def input(assigns) do
    ~H"""
    <div phx-feedback-for={@name}>
      <.label for={@field.id}><%= @label %></.label>
      <input
        type={@type}
        name={@name}
        id={@id}
...

I don’t know if this is because my changeset is schemaless because I this this component working to register a user for example

defmodule Pento.Promo.Recipient do
  import Ecto.Changeset

  @types %{email: :string, first_name: :string}
  defstruct [:email, :first_name]

  def changeset(%__MODULE__{} = user, attrs) do
    {user, @types}
    |> cast(attrs, Map.keys(@types))
    |> validate_required([:first_name, :email])
    |> validate_format(:email, ~r/@/)
  end
end

Marked As Solved

tomkonidas

tomkonidas

Try passing in your input fields like:

field={f[:key_on_changeset]}

Where Next?

Popular in Questions Top

senggen
Erlang/OTP 25 [erts-13.2.2] [source] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:1] 15:22:35.803 [error] gen_event {lager_file_backend...
New
vonH
In asking this question I am more interested about the expressiveness of the language itself and less concerned about the availability of...
New
ycv005
I have followed this StackOverflow post to install the specific version of Erlang. And When I am running mix ecto.setup then getting fol...
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
polypush135
As many of you may have realized by now (sorry for all the posts here) I’ve been working on a db problem where I’m trying to aggregate a ...
New
vertexbuffer
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
script
If I have a string “1000 cfu/ml” . I want to remove the characters and / and space . So the string is like this "1000" What is the ...
New
vac
Hi, I'm quite new in Elixir and I'm trying to format a string to a PEM format. I have the certificate value like MIIDBTCCAe2...... and ...
New
stefanluptak
Hello everybody, usually, I use a 29" ultra-wide monitor for VSCode which can easily accomodate explorer (files panel) + file with code ...
New
9mm
I am constructing a JSON object (map) and I need to conditionally set a field. I’m trying to write proper elixir-way code… and I’m at a l...
New

Other popular topics Top

srinivasu
How to handle excepions in elixir? Suppose i have A, B, C ,D, E modules. and each module has get() function. A.get() method will call th...
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
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
KronicDeth
Elixir plugin for JetBrain’s IntelliJ Platform (including Rubymine) This is a plugin that adds support for Elixir to JetBrains IntelliJ...
289 35421 110
New
mcarvalho
What is the difference between System.get_env and Application.get_env? For example, what are best practices to use one versus another.
New
chensan
I have a User schema with a :from_id field set to type :string: defmodule TweetBot.Repo.Migrations.CreateUsers do use Ecto.Migration ...
New
ashish173
I am using Ecto timestamps with postgres, I can see the timestamps() use the :naive_dateime but for my use case I wanted to store the ti...
New
electic
Hi, I am new to Elixir. I am trying to use the DateTime component to insert a date into MySQL however the there seems to be no way to fo...
New
beno
I will often find my self writing things similar to: case some_value do nil -&gt; something() "" -&gt; something() _ -&gt; someth...
New
magnetic
Hey :wave:t3: Elixir community, I’ve been learning Elixir, and working on some side projects. My editor of choice is VSCode, and althoug...
New

We're in Beta

About us Mission Statement