Forms without redirect

Ok, I got this to work, but I’m not using target="_top". I’m using a Stimulus controller and listening for the turbo:submit-end event and then performing a Turbo.visit on a successful form submission. Invalid form errors are handled by Turbo by returning a 422 response.

The code if anyone is interested:

import { Controller } from "stimulus"
import * as Turbo from "@hotwired/turbo"


export default class extends Controller {
  connect() {
    this.element.addEventListener('turbo:submit-end', function (event){
        if (event.detail.success) {
            Turbo.visit(window.location.href)
        }
    })
  }
}

Then my turbo-frame:

<turbo-frame id="contact-name-edit" data-controller="form"></turbo-frame>