josefarias / hotwire_combobox

An accessible autocomplete for Ruby on Rails.
https://hotwirecombobox.com
MIT License
436 stars 26 forks source link

Fix name_when_new validation on multiselect with form scope name #169

Closed chloerei closed 2 months ago

chloerei commented 2 months ago

Example form:

form_with scope: :foo, url: "some_path" do |form|
  form.combobox :bar, multiselect_chip_src: "some_path", name_when_new: "foo[bar]"
  form.combobox :bar, multiselect_chip_src: "some_path", free_text: true
end

It will raise

Validation failed: Name when new must match the regular name ('bar', in this case) on multiselect comboboxes.

But name foo[bar] is correct. The comparison in the validation is the parameter name, which is not the name of the actual input.