Hi, just wondering if this version of select/4 works as described in the documentation:
options are expected to be an enumerable which will be used to generate each respective option. The enumerable may have:
keyword lists - each keyword list is expected to have the keys :value and :label. Additional keys such as :disabled may be given to customize the option
When I try to run:
select(form, :role, [[key: "Admin", value: "admin", disabled: true],
[key: "User", value: "user"]])
I get:
(ArgumentError) lists in Phoenix.HTML and templates may only contain integers representing bytes, binaries or other lists, got invalid entry
Iβm also confused whether I need to use βkeyβ or βlabelβ as the key in the keyword list. I think Iβve tried every conceivable permutation of strings and atoms all to no avail.
My goal is to add a class on to each option. Thanks.
Hmm, your example worked here when copy/pasted in. Maybe your form
is corrupt. Just as a test can you replace the form
argument with the atom :form
instead and see if you donβt get an error? If no error then something is wrong with the form, in which case a minimal example that we can copy/paste in to IEX would help to diagnose further.
How strange! Iβve just popped the select code from the documentation into an existing working form that uses a select of the 2nd type (two-item tuples). Same error, so Iβm not sure I can blame the form Iβve tried switching to an atom with the same result.
** (ArgumentError) lists in Phoenix.HTML and templates may only contain integers representing bytes, binaries or other lists, got invalid entry: {:key, "Admin"}
What version of Phoenix, Phoenix.HTML, and etc. are you running? Iβm running current stable on all.
Specifically, what is your mix.lock
file contents?
Phoenix is at 1.3.0
Phoenix.HTML looks like 2.9.3. Iβm not sure how to check to be honest
I can see that Phoenix.HTML looks to be at 2.10.5 in the documentation - how do I bump if thatβs worth trying?
mix deps.update phoenix_html
{:phoenix_html, β~> 2.9β, [hex: :phoenix_html, optional: true]}, {:plug, β~> 1.0β, [hex: :plug, optional: false]}]},
βphoenix_htmlβ: {:hex, :phoenix_html, β2.9.3β, β1b5a2122cbf743aa242f54dced8a4f1cc778b8bd304f4b4c0043a6250c58e258β, [:mix], [{:plug, β~> 1.0β, [hex: :plug, optional: false]}]},
Here are the mix file deps
defp deps do
[{:phoenix, β~> 1.3.0β},
{:phoenix_pubsub, β~> 1.0β},
{:phoenix_ecto, β~> 3.0β},
{:postgrex, β>= 0.0.0β},
{:phoenix_html, β~> 2.6β},
{:phoenix_live_reload, β~> 1.0β, only: :dev},
{:gettext, β~> 0.11β},
{:cowboy, β~> 1.0β},
{:httpoison, β~> 0.8β},
{:httpotion, β~> 3.0.2β},
{:sweet_xml, β~> 0.6β},
{:floki, β~> 0.17.0β},
{:erlsom, git: βgit@github.com:willemdj/erlsom.gitβ},
{:plug, β~> 1.0β}
]
end
1 Like
Fixed It was running on an older version of Phoenix.HTML
Thanks @OvermindDL1
1 Like