north_celt
I’m having trouble rendering an Ecto.Enum array field in liveview.
Here’s the offending heex line:
<:item title="Services offered"><%= @facility.services_offered %></:item>
and here’s the line in my schema:
field :services_offered, {:array, Ecto.Enum}, values: [:dance, :swim, :yoga]
and this is the error it gives me:
** (ArgumentError) lists in Phoenix.HTML and templates may only contain integers representing bytes, binaries or other lists, got invalid entry: :dance
stacktrace:
(phoenix_html 3.3.1) lib/phoenix_html/safe.ex:81: Phoenix.HTML.Safe.List.to_iodata/1
(phoenix_html 3.3.1) lib/phoenix_html/safe.ex:49: Phoenix.HTML.Safe.List.to_iodata/1
(parity 0.1.0) lib/myapp_web/live/facility_live/index.ex:68: anonymous fn/3 in MyAppWeb.FacilityLive.Index.render/1
Any pointers here? Googling has gotten me nowhere.
Trending in Questions
I’m working on a project that simulates the bumbl example in the programming phoenix book. It acts almost like an email client. We have a...
New
Hello,
I know there is an approach for handling lists that allows for optimized traversal, but I can’t recall the specific method (somet...
New
I’m seeing that a list inside a Kino.DataTable will be interpreted as a charlist, even if the Kino.configure() is set to charlists: :as_l...
New
Documentation
While reading the Scoped Routes section, I noticed that the documentation currently refers to a problem without explainin...
New
So my question is quite simple and i have found no conclusive answer on forum, google or AI.
Should we use :erlang.float for Integer to ...
New
Hi, I’ve just set up an application with ash_authentication. There is only magic link strategy for now, so there is no confirmation add o...
New
If a change or preparation module uses Ash.Changeset.get_argument/2 or Ash.Query.get_argument/2 (or any of the other get_argument functio...
New
Other Trending Topics
I am happy to introduce the very α version of the new programming language compiled to BEAM.
Welcome Cure.
It has literally three kille...
New
Hi there! We created Gust: A task orchestrator inspired by Airflow.
For those who have never heard about Aiflow, it’s a Python-based wor...
New
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
Xamal is a deployment tool for Elixir apps that deploys native releases to bare metal servers over SSH. It’s a port of GitHub - basecamp/...
New
Corex is an accessible, unstyled UI component library for Phoenix that integrates Zag.js state machines using Vanilla JavaScript and Live...
New
With AI doing more of the implementation work, I’ve been wondering how much coding I should deliberately keep doing myself.
My main conc...
New
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #library
- #deployment
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #elixirconf
- #channels
- #exunit
- #discussion
- #code-sync
- #podcasts
- #javascript
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixirconf-us
- #ai
- #blog-post
- #elixir-ls
- #phoenix_html
- #iex
- #graphql
- #genstage
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #hex
- #security
- #metaprogramming











Showing Posts 1 to 8- Show Best Posts
- Show All (oldest first)
- Show All (newest first)
v0idpwn
You can’t render a list of atoms. You should convert it to something representable. For example:
kokolegorille
or You can try this…
<:item title="Services offered"><%= inspect @facility.services_offered %></:item>north_celt
I get that, but it seems like LiveView automatically renders atoms from enums correctly, as I have a single-select enum type already and it renders fine (without me casting all of the enums to string) It seems like maybe this should be fixed in
Phoenix.Safe?v0idpwn
The problem is not on Phoenix. When you try to interpolate a term,
Kernel.to_string/1is called on the term. The implementation for atom is simplyAtom.to_string/1. The implementation for lists raises the error you’re seeing: elixir/lib/elixir/lib/list.ex at v1.14.4 · elixir-lang/elixir · GitHub.north_celt
It’s happening in
Phoenix.Html.Safe: phoenix_html/lib/phoenix_html/safe.ex at main · phoenixframework/phoenix_html · GitHubI think maybe it could have a line like
but I’m super new to phoenix, so I could be way off!
v0idpwn
You’re actually right, my bad
But the reasoning is the same from List.to_string/1, I guess.
north_celt
Not at all, I appreciate the help!
I created a PR for this here: Add support for lists of atoms by loganmac · Pull Request #422 · phoenixframework/phoenix_html · GitHub
LostKobrakai
I‘d expect lists are not supported by design. The implementation for lists seems to be there to support the structure of iodata/iolists, rather than lists of user provided values.