I found this code useful to delete a value saved as an entity reference:

$customer = Customer::load($form_state->getValue('customer_id'));
$customer->get('field_contact_person')->removeItem(0);
$customer->save();

 

 

 

 

Saved you some valuable time?

 

Donate and get more free time-saving code on this website in the future.