TwistingTwists
Custom `input_type` for Custom Structs
I need to create a form for custom defined struct which has another nested struct (to be represented as formarray)
%MyOuterStruct{ key: :value,
inner_key:
%{16=> %InnerStruct{key2: :value2},
17=> %InnerStruct{key2: :value3}
}
I have defined changesets for both of these structs in their respective files.
Issue I am facing:
no function clause matching in Phoenix.HTML.Form.input_type/3
Called with 3 arguments
%{16 => %InnerStruct{key2: value}}
:inner
%{"email" => :email_input, "password" => :password_input, "search" => :search_input, "url" => :url_input}
basically in a liveview form:
...
<%= create_inner f.data.outer.inner ,:inner %>
...
and input_helpers.ex contain
def create_inner(form, field, input_opts \\ [], data \\ []) do
type = HTML.Form.input_type(form, field) |> IO.inspect(label: "type of input")
.... more code ...
end
How do I create a custom input helper for my nested struct?
First Post!
al2o3cr
Usually you’d use inputs_for in this situation; I’m not sure if that’s a good fit depending on what the keys inside of inner_key (16 and 17 in the example) mean.
What shape of parameters is your event handling / changeset code expecting for MyOuterStruct?
Popular in Questions
I have an umbrella app.
Some of the apps inside depend on other apps in the umbrella, unsurprisingly.
I'm writing a test for one of t...
New
As a follow up to my earlier question:
I have the code compiling and running but not getting a successful login from the rest server. ...
New
Hey guys.
I'm new to elixir and im really stocked about it. But I ran into a bit of problem - I need to convert a date sting, for examp...
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
I have a another noob question about loop. Since elixir is immutable, while loop is not directly possible.
total = 10
while total != 0
...
New
Hi,
I need to transform a list of numbers into a map where the keys are the indexes and the values are the original values of the list....
New
When I run the Plug and I recompile I wind up having to use Ctrl C to quit iex and start again. Witht the help of rlwrap I can use the cu...
New
Mix format works fine if run from the cmd. I’ve followed this to facilitate the implementation into VSC which involves downloading an ext...
New
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
To my knowledge, put_in, Map.update etc. all have the one limitation of not automatically creating intermediate keys when needed (for exa...
New
Other popular topics
Manning 2016 Halloween weekend sale via Deal of the Day
Friday, October 28 - Half off all MEAPs - code WM102816LT
Saturday, October 29 ...
New
In Ruby, I can go:
User.find_by(email: "foobar@email.com").update(email: "hello@email.com")
How can I do something similar in Elixir? ...
New
I have a relationship of love and hate with Elixir. Lots of things are just absolutely right, but there are some things that are kind of ...
New
This post is a wiki (feel free to hit the edit button near the bottom right of this post to add your own changes!)
This post collects co...
New
This release brings a number of exciting features, including integration with the new Phoenix LiveDashboard and Phoenix LiveView. There h...
New
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,
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
Is there a way to get the call stack or stack trace at any point in the code? Not from exceptions, but an expression that returns how the...
New
by Lance Halvorsen
Elixir and Phoenix are generating tremendous excitement as an unbeatable platform for building modern web application...
New
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







