I have a multiple values field on the user
entity. This field is field_data
.
There are several values in this field. I want to delete all of them.
I tried the following code:
for ($i = 0; $i < count($user->field_data->value()); $i++) {
$user->field_data[$i]->delete();
}
But I get errors about ->delete()
not being a method on this object. I also tried with ->clear()
to no avail.
I've been looking for examples on Google for how to do this, but my Google-fu is not so strong today.