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

Conversation

noriyotcp
Copy link

@noriyotcp noriyotcp commented Feb 10, 2022

Summary

When you give the value to f.submit, the same value sets to the value of data-disable-with.

= f.submit 'Submit', class: 'btn btn-primary'
<input type="submit" name="commit" value="Submit" class="btn btn-primary" data-disable-with="Submit">

But when you give the :value option, two values are not the same.

= f.submit value: 'Submit', class: 'btn btn-primary'
<input type="submit" name="commit" value="Submit" class="btn btn-primary" data-disable-with="Create">

Create seems to come from i18n as the default value. https://github.com/svenfuchs/rails-i18n/blob/99cfa35268ad20ec1193c670a7ee2a4705140a3d/rails/locale/en.yml#L151

This PR sets the value of :value option to the value of data-disable-with

@rails-bot rails-bot bot added the actionview label Feb 10, 2022
@noriyotcp noriyotcp changed the title f.submit: Make the same as the value of data_disable_with the value… f.submit: Make the same as the value of data_disable_with the value of the explicit :value option Feb 10, 2022
@noriyotcp noriyotcp changed the title f.submit: Make the same as the value of data_disable_with the value of the explicit :value option f.submit: Set the the value of the explicit :value option to the value of data_disable_with Feb 10, 2022
@noriyotcp noriyotcp changed the title f.submit: Set the the value of the explicit :value option to the value of data_disable_with f.submit: Set the the value of the explicit :value option to the value of data-disable-with Feb 11, 2022
@skipkayhil
Copy link
Member

Hey, @noriyotcp, thanks for the PR! I'm a little bit confused about the desire for this change. Is there a reason you wouldn't be able to use = f.submit 'Submit', class: 'btn btn-primary'?

It seems to me like the two different apis serve different purposes:

  • the positional parameter sets both the value and data-disables-with attributes
  • value: and data-disables-with: would set individual values

I think it would be surprising to me if value: set other attributes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants