7rans

7rans

Access changeset form data in HTML w/o input component?

How do I access changeset data in my HTML, passed in via form: to_form(changeset), when not using a Phoenix input component? Am I really supposed to do this:

<p><%= @form[:foo].value %></p>

Or am I missing something?

First Post!

LostKobrakai

LostKobrakai

Yes. That’s how you get access to the value of the input. It’s not clear if that’s what you’re looking for though.

Last Post!

7rans

7rans

I have a Changeset it becomes a Form via to_form which is passed into the template as @form. For input components I can just use <input field={f[:foo]} ...> where f comes from <.form :let={f} for={@form}.... But if I just want to see the (changed) data in a read-only way what do I use? If I were just passing in the struct/data (not the changeset via a form), I’d use <%= @data.foo %>, or course.

Another thing I just noticed trying to use .value, embeds end-up with strings for keys not symbols. So now I have to switch all my my dot syntax to brackets. So what was once @data.foo.bar is now @form[:foo].value["bar"]. This just seems goofy.

Where Next?

Popular in Questions Top

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
Lily
In templates/appointment/index.html.eex: &lt;%= for appointment &lt;- @appointments do %&gt; &lt;tr&gt; &lt;td&gt;&lt;%= appoi...
New
joeerl
Hello again - after a longish gap I’ve decided I really must dig into Elixir and see what’s been happening here - so I have a few questio...
New
jay1
Why is it that the mnesia database isn’t the most preferred database for use in Elixir/Phoenix?
New
sen
Hi All, I set a environment variables in dev.exs , like below code. when i start server, how can i set the ${enable} value? thanks. d...
New
jerry
Good day to you all. I have been struggling to get a query involving like and ilike to work. Can anyone assist me on this, please? pro...
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

Other popular topics Top

vonH
In asking this question I am more interested about the expressiveness of the language itself and less concerned about the availability of...
New
JakeBecker
TL;DR: I’ve just released an implementation of Microsoft’s IDE-independent Language Server Protocol for Elixir. It adds language support ...
1144 55125 245
New
gshaw
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
AstonJ
Seen any cool LiveView demos, sample apps or examples? Please post them here! :003:
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
TunkShif
This post is an instruction guide to help you setup your Neovim for Elixir development from scratch. It includes general information on h...
274 42716 114
New

We're in Beta

About us Mission Statement