From 755e95e6441b0706646e779cd2082b7a0e0762d6 Mon Sep 17 00:00:00 2001 From: Jean-Roman Garnier Date: Sun, 24 Nov 2019 22:10:55 +0000 Subject: [PATCH] Fix massive fields sending incorrect data in POST request --- re2o/templatetags/massive_bootstrap_form.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/re2o/templatetags/massive_bootstrap_form.py b/re2o/templatetags/massive_bootstrap_form.py index 20d468a1..d4460de7 100644 --- a/re2o/templatetags/massive_bootstrap_form.py +++ b/re2o/templatetags/massive_bootstrap_form.py @@ -520,6 +520,14 @@ class MBFField: "}} );" ) + # Make sure the visible element doesn't have the same name as the hidden elements + # Otherwise, in the POST request, they collide and an incoherent value is sent + self.js_script += ( + '$( "#{input_id}" ).ready( function() {{' + ' $( "#{input_id}" ).attr("name", "mbf_{f_name}");' + "}} );" + ) + def fill_js(self): """ Fill the template with the correct values """ self.js_script = self.js_script.format(