stimulusreflex / stimulus_reflex

Build reactive applications with the Rails tooling you already know and love.

Home Page:https://docs.stimulusreflex.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

reflex form parameter lists are uniqued

LukeClancy opened this issue · comments

Bug Report

Describe the bug

Hello, love stimulus reflex, it makes things so simple. This is the first issue I have had in months, and I can work around it, so no rush. When creating a parameter list in a form, each key and value is made unique. This removes functionality for repeated input. Compared to rails controllers, this is not regular functionality. Thank you for any help.

To Reproduce

###view

= form_with url: user_page_path(id: Current.user.slug), multipart: true, method: :patch do
    %div{id: "user_tidbits_form", data: { controller: 'user-page-tidbits' }}
        = hidden_field_tag 'user[test][]', 'a'
        = hidden_field_tag 'user[test][]', 'a'
        = hidden_field_tag 'user[test][]', 'b'
        %button.btn{'data-reflex': 'click->User#tester'} yeet

###reflex

class User < ApplicationReflex
	before_reflex :make_as_list
	def tester
		morph :nothing
	end
	private
	def make_as_list
		5.times{ Rails.logger.info(params['user']) }
	end	
end

Expected behavior

Log output should be
{"test"=>["a", "a", "b"]}

Actual behavior

Log output is
{"test"=>["a", "b"]}

Versions

StimulusReflex

gem: stimulus reflex 3.4.1
yarn: stimulus_reflex@3.4.1

External tools

  • Ruby: 2.7
  • Rails: 6.0.4.1

Browser

firefox

@LukeClancy saw your post in the Discord - while I don't know how to fix it, I understand what you're saying is happening.

I made a simple sample app that will demonstrate the issue directly.

https://github.com/thewatts/reflex-params-example

Thanks so much, @thewatts! This will be super helpful.

This invites a new test, I'd argue