rails/jquery-ujs

Values of array fields in fieldsets duplicated when using remote true

kreintjes opened this issue · 4 comments

Since updating to jquery-rails 4.1.0 I have a strange problem when using an array field (field with name ending in brackets) in a fieldset. The values are duplicated on submit. Suppose I have the following code in a view:

= form_tag(tests_path, remote: true) do
  fieldset
    = label_tag('Tests')
    = text_field_tag('tests[]', 'foobar')
  = submit_tag

When submitting this, I would expect params['tests'] to equal ["foobar"] (as it did with jquery-rails 4.0.5). However, now params['tests'] equals ["foobar", "foobar"] (the value is duplicated). This problem does not occur when disabling the remote form option, or when replacing the fieldset with a div. Am I missing something obvious or is this a bug in the jquery-ujs adapter?

Just for the sake of completeness, are you positive jquery-ujs isn't being included twice or being compiled twice into your assets?

@JangoSteve Yes. I have created a fresh app to demonstrate this issue. See: https://github.com/kreintjes/jquery-ujs-issue

Hi guys, I also have the same issue. If fields are in a div it is ok, but if you put them in a fieldset then the value is duplicated.

Same problem here.