Skip to content

Commit 60e1150

Browse files
committed
Fix the value of submit buttons being lost on submisison
Fixes #3513
1 parent 32e6b14 commit 60e1150

2 files changed

Lines changed: 17 additions & 1 deletion

File tree

spec/integration/actions/edit_spec.rb

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -766,6 +766,22 @@ class HelpTest < Tableless
766766
end
767767
end
768768

769+
context 'with a submit button with custom value', js: true do
770+
before do
771+
@player = FactoryBot.create :player
772+
773+
visit edit_path(model_name: 'player', id: @player.id)
774+
775+
execute_script %{$('.form-actions [name="_save"]').attr('name', 'player[name]').attr('value', 'Jackie Robinson')}
776+
find_button('Save').trigger('click')
777+
end
778+
779+
it 'submits the value' do
780+
@player.reload
781+
expect(@player.name).to eq('Jackie Robinson')
782+
end
783+
end
784+
769785
context 'with missing object' do
770786
before do
771787
put edit_path(model_name: 'player', id: 1), params: {player: {name: 'Jackie Robinson', number: 42, position: 'Second baseman'}}

src/rails_admin/ui.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ import I18n from "./i18n";
9292
$("<input />")
9393
.attr("type", "hidden")
9494
.attr("name", $(this).attr("name"))
95-
.attr("value", true)
95+
.attr("value", $(this).attr("value"))
9696
);
9797
if ($(this).is("[formnovalidate]")) {
9898
form.attr("novalidate", true);

0 commit comments

Comments
 (0)