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
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
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.
Popular in Questions
Other popular topics
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
- #api
- #forms
- #metaprogramming
- #security
- #hex









