We have a new requirement to stop an admin from deleting a contact's email if that email is found in one of our other systems. I am trying to do this through a validateForm hook. I can figure out the logic of finding the email in another system. But how can I check: 1. That the form is trying to delete or update an email (vs adding an email)? 2. Identify which email is being deleted?
I can't tell where to find the action being taken, nor which email is being deleted. Also, if I set an error (as a test), the error shows correctly, but the deleted email is gone from the view of the form (I would like for it to stay there).
Is there another hook I should be using for this?
My other option would be to use the buildForm or similar hook to make that field readonly prior to the form showing up. But I feel it's safer to block a delete.
Would love some pointers on either method. Thanks!