Closed difernandez closed 1 year ago
Just leaving this here to confirm that this does indeed fix the issue we were experiencing with #421. Thank you for your work! Great job simplifying it in the process 💪 🎉
Thanks for confirming, I'm glad it works!
Motivation / Background
This Pull Request has been created because tags input has had some inconsistent behaviors in the past related to the string returned and the token that separated the tags in said string. Plus, it seemed a bit counter-intuitive that a tags/multiselect input returned a string instead of an array.
Closes #335 Closes #341 Closes #421
Detail
This Pull Request changes the tags input so it returns an array of strings instead of a token-separated string. It does so by relying on the default behavior of a regular rails select with
multiple: true
. This allowed me to simplify the input a lot, as now a couple of things, such as hidden input with blank value and tracking of the array value, are done under the hood. The input now works almost identically as doingf.input :foos, as: :select, multiple: true
, with the added bonus of being able to setvalue
anddisplay_name
, and having theaddable
function defined for non-AR relation uses. A disclaimer was added to inform of the return type and a gotcha present in multi selects that's important when using with Postgres' array column.Additional information
With a
Purchase
model that has:foos
column of Postgres array typeAn
acts_as_taggable_on :aato_tags
, from the library acts_as_taggable_on And an admin form with the following form:It looks like this:
https://github.com/platanus/activeadmin_addons/assets/12057523/76d36697-2deb-4fb3-bad3-793f62eab19a
Checklist
Before submitting the PR make sure the following are checked: