Multiple form buttons with transition.submission #1294
-
More out of curiosity more than anything, but at the moment having two buttons (in my example one to edit and one to delete) and transition.submission causes both buttons to change their text on form submit. I'm interested to know if there's a way we can distinguish one intention from the other in the transition and apply the text changes accordingly? example button code: <button className="btn" name="button">
{transition.submission ? "Saving..." : "Edit Resource"}
</button>
<button className="btn bg-transparent border border-color-red-600 text-red-600 hover:bg-red-600 hover:text-white" type="submit" name="button" value="delete">
{transition.submission ? "Deleting..." : "Delete Resource"}
</button> |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
I don't know how your form is built but my guess is to have two different form. One for the edit with all fields and another for the delete.
Now, when Exemple:
I hope its helping you 🤞 |
Beta Was this translation helpful? Give feedback.
I don't know how your form is built but my guess is to have two different form. One for the edit with all fields and another for the delete.
You can add an hidden field on each form that content a type of form. For exemple
Now, when
transition.submission
is defined you have access to formData fromtransition?.submission?.formData.get("type")
.Exemple: