Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

f.submit: Set the the value of the explicit :value option to the value of data-disable-with #44389

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
13 changes: 13 additions & 0 deletions actionview/CHANGELOG.md
@@ -1,3 +1,16 @@
* Set the value of the explicit `:value` option to `data-disable-with`

```ruby
= f.submit value: 'Submit'

# Before
# => <input type="submit" name="commit" value="Submit" data-disable-with="Create">
# After
# => <input type="submit" name="commit" value="Submit" data-disable-with="Submit">
```

*Noriyo Akita*

* Allow templates to set strict `locals`.

By default, templates will accept any `locals` as keyword arguments. To define what `locals` a template accepts, add a `locals` magic comment:
Expand Down
1 change: 1 addition & 0 deletions actionview/lib/action_view/helpers/form_tag_helper.rb
Expand Up @@ -1005,6 +1005,7 @@ def set_default_disable_with(value, tag_options)
elsif ActionView::Base.automatically_disable_submit_tag
disable_with_text = tag_options["data-disable-with"]
disable_with_text ||= data["disable_with"]
disable_with_text ||= tag_options["value"]
disable_with_text ||= value.to_s.clone
tag_options.deep_merge!("data" => { "disable_with" => disable_with_text })
end
Expand Down
7 changes: 7 additions & 0 deletions actionview/test/template/form_tag_helper_test.rb
Expand Up @@ -632,6 +632,13 @@ def test_empty_submit_tag
)
end

def test_submit_tag_with_value_option
assert_dom_equal(
%(<input data-disable-with="Update" name='commit' type="submit" value="Update" />),
submit_tag("Save", value: "Update")
)
end

def test_empty_submit_tag_with_opt_out
ActionView::Base.automatically_disable_submit_tag = false
assert_dom_equal(
Expand Down