Incorrect inflection for param key of association ids
laurenfackler opened this issue · comments
For checkbox inputs of associations with unique pluralization requirements, e.g. specialty/specialties, ExAdmin incorrectly pluralizes the <association>_ids
param key: specialtys
.
In https://github.com/smpallen99/ex_admin/blob/master/lib/ex_admin/param_associations.ex#L34, if you replace
new_key =
String.replace_suffix(key_as_string, "_ids", "s")
|> String.to_atom()
with
key_as_string
|> String.replace("_ids", "")
|> Inflex.pluralize()
|> String.to_atom()
it fixes the issue.
As a quick workaround, you can name the collection field so it takes the current pluralization logic, a simple prefix of s
, into account. For example, instead of
inputs(:specialties, as: :check_boxes, collection: Repo.all(Specialty))
which will change the params key from specialty_ids
to specialtys
, you can do
inputs(:specialtie, as: :check_boxes, collection: Repo.all(Specialty))
which changes the params key from specialtie_ids
to specialties
, which is what's needed.