Skip to content

Commit

Permalink
Fix the value of submit buttons being lost on submisison
Browse files Browse the repository at this point in the history
Fixes #3513
  • Loading branch information
mshibuya committed Jun 26, 2022
1 parent 32e6b14 commit 60e1150
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
16 changes: 16 additions & 0 deletions spec/integration/actions/edit_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -766,6 +766,22 @@ class HelpTest < Tableless
end
end

context 'with a submit button with custom value', js: true do
before do
@player = FactoryBot.create :player

visit edit_path(model_name: 'player', id: @player.id)

execute_script %{$('.form-actions [name="_save"]').attr('name', 'player[name]').attr('value', 'Jackie Robinson')}
find_button('Save').trigger('click')
end

it 'submits the value' do
@player.reload
expect(@player.name).to eq('Jackie Robinson')
end
end

context 'with missing object' do
before do
put edit_path(model_name: 'player', id: 1), params: {player: {name: 'Jackie Robinson', number: 42, position: 'Second baseman'}}
Expand Down
2 changes: 1 addition & 1 deletion src/rails_admin/ui.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ import I18n from "./i18n";
$("<input />")
.attr("type", "hidden")
.attr("name", $(this).attr("name"))
.attr("value", true)
.attr("value", $(this).attr("value"))
);
if ($(this).is("[formnovalidate]")) {
form.attr("novalidate", true);
Expand Down

0 comments on commit 60e1150

Please sign in to comment.