assuming we have a create endpoint that has something like
def create
@candidate = Candidate.new(candidate_params)
@candidate.user_id = current_user.id
@candidate.save!
respond_to do |format|
format.turbo_stream
end
rescue
respond_to do |format|
format.turbo_stream
end
end
and we have a stimulus controller like
import { Controller } from "@hotwired/stimulus"
export default class extends Controller {
reset(event) {
this.element.reset()
}
}
question: in the case that the candidate (or whatever) isn't saved, sure we understand how to send a different turbo partial back to the browser, but how do we communicate to the stimulus controller that the object wasn't created correctly? And therefore, don't reset the form, let the user do that so they can remember what they wrote and fix it