Add option to opt out of Turbo for forms by default and require manual opt in
See original GitHub issueAnecdotally, one of the biggest deterrents for people upgrading from Turbolinks to Turbo has been the way forms are handled. For Rails users heavily invested in UJS, it’s a mammoth task to rework all the forms to work with Turbo.
I’ve worked around this in the past in Rails by monkey patching form_with
to disable Turbo with data-turbo=false
; but I think it’d be a great idea to allow a global setting within Turbo to navigate only on forms that have opted in with data-turbo=true
.
I’m thinking it could be set at initialization time like: Turbo.start({ forms_opt_out_by_default: true })
I’m happy to spend some time working on this if this is something maintainers would like to support so just opening this issue to get people’s thoughts!
Issue Analytics
- State:
- Created 2 years ago
- Reactions:10
- Comments:5 (2 by maintainers)
Top Results From Across the Web
Navigate with Turbo Drive - Hotwire Turbo
Links or forms with Turbo Drive disabled will be handled normally by the browser. If you want Drive to be opt-in rather than...
Read more >Dynamic forms with Turbo - Thoughtbot
In this case, we need search-params#encode to precede element#click so that the name-value pair is encoded into the [href] attribute before we ...
Read more >How to Manually Update Smart Cache Version - Egnyte Support
Login with the default username (admin) password (turbocharged). Then multiple options will appear. Choose the upgrade option (No. 10) from those options ......
Read more >Custom Form Handling With Turbo - Source Diving
Turbo will be a default part of Rails from Rails 7, replacing Turbolinks and ... One option is to use Turbo up to...
Read more >R Installation and Administration
After downloading manually you need to execute tools/link-recommended from ... The default can be overridden by setting the environment variable R_RD4PDF .
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@ayushn21 have you tried setting
<html data-turbo="false">
or<body data-turbo="false">
, and then incrementally opting into Turbo on an individual<a>
and<form>
basis?If it’s
<form>
elements that are the issue, It might be more straightforward to disable all elements, and then opt back in<a>
elements:Thanks @seanpdoyle. That’s a great stopgap solution on the JS side of things.
I do agree with @leastbad that it’d be great to have a cleaner way to prevent Turbo from navigating on forms by default though. The chat we were having in the StimulusReflex Discord was also centered on what level should this setting be configured (i.e. within Turbo or through a server side helper like
config.action_view.form_with_generates_turbo_forms
)If you believe the right way to go about this would be to handle the exclusion of forms on the server rather than within Turbo, I reckon it makes sense to close this issue and we can take the discussion to rails/rails.
Thanks for your input!