Does Turbo.setFormMode("optin")
disable turbo requests in links?
I’m updating a mature app using Rails 6.1, recently added gem turbo-rails
1.5.0, gem importmap-rails
1.2.3 to start converting forms to Hotwire.
# app/javascript/application.js
import "@hotwired/turbo-rails"
Turbo.setFormMode("optin")
In a translation page erb
template, I have links that should GET a turbo-stream request for a tiny edit form. The response should update a separate turbo-frame (or a div, have tried both), elsewhere on the page, replacing it with the edit form.
link_to(label, edit_translation_path(id: t_tag, locale: @lang.locale),
data: { turbo: true, turbo_frame: "translation_ui",
tag: t_tag, role: "show_tag" })
The issue is that these links are not sending request.format turbo-stream
, they’re sending request.format text/html
- I can see this in the log output, and confirm it if I break in the controller action.
Things I have tried:
- modifying the link path
edit_translation_path(format: "turbo-stream")
- modifying the route format in config/routes.rb
get(:edit, to: "translations#edit", as: "edit_translation", defaults: { format: :turbo_stream })
- adding
Turbo.session.drive = true
toapp/javascript/application.js
- changing
data: { turbo: true }
todata: { turbo_method: :get }