Form rendering problems with field {:array, :boolean}

Thanks Frank! My mistake was definitely not looking more into the limitations of the checkbox input in the core_component. See How to make checkbox work with form bindings Phoenix LV? - #2 by LostKobrakai.

For future reference, this thread is also related: How to wire up a Phoenix form for a field {:array, :string}?

What I ended up with is an ugly ass solution that works:

  • A :check_options assign initiated with existing my_list values (if present)
  • A handrolled vanilla <input type="checkbox" ...> inside of a :for div
  • A phx-change handler to handle the checkboxes on/off and sanitize them into my temporary checked_options in my assign
  • And finally a a Map.merge in my save handler that take this checked_options and put it into my params prior to generating the changeset

So in other words, I am binding the data manually with handlers and making sure it is merged into the params/changeset rather than relying on the field={@form[:my_list]} convenience. A whole lot uglier but at least I can move on :saluting_face: