Warning for unused variable "value" in form radio_button that is being used

I think I may have come across a bug. I keep getting this warning:

warning: variable "value" is unused (if the variable is not meant to be used, prefix it with an underscore)

Here is my code:

<%= label class: "radio-inline" do %>
  <%= radio_button f, :role, value="admin" %> Admin
<% end %>

Here is the rendered HTML which shows value being used:

<input id="user_role_admin" name="user[role]" type="radio" value="admin" checked="">

Hello, try with:

<%= radio_button f, :role, value: "admin" %> Admin


Sadly, that results in this error:

lists in Phoenix.HTML and templates may only contain integers representing bytes, binaries 
or other lists, got invalid entry: {:value, "admin"}

Sorry, my bad, :blush: I checked now how I used radio buttons in my code, no value: attribute, just its value like:

<%= radio_button f, :role, "admin" %> Admin


That works! Thanks!

1 Like