bin/rails g stimulus reset_form
<% form_data = { controller: "reset-form", action: "turbo:submit-end->reset-form#reset" }%>
<%= form_with model: @message, data: form_data do |form| %>
<%= form.text_field :body %>
<%= form.submit %>
<% end %>
import { Controller } from "@hotwired/stimulus" | |
// Connects to data-controller="reset-form" | |
export default class extends Controller { | |
reset() { | |
this.element.reset() | |
} | |
} |