Add bridged_form_with helper for bridge form controller.

This commit is contained in:
Denis Švara
2026-01-07 11:30:09 +01:00
parent 4cbc2c676d
commit 58664f88de
+19
View File
@@ -9,4 +9,23 @@ module FormsHelper
form_with(**attributes, data: data) { }
end
end
def bridged_form_with(**attributes, &)
data = attributes.delete(:data) || {}
controllers = [ data[:controller], "bridge--form" ].compact.join(" ").strip
actions = [
data[:action],
"turbo:submit-start->bridge--form#submitStart",
"turbo:submit-end->bridge--form#submitEnd"
].compact.join(" ").strip
data[:controller] = controllers
data[:action] = actions
if block_given?
form_with **attributes, data: data, &
else
form_with(**attributes, data: data) { }
end
end
end