I am writing an extension on EE 3.5.11 and I am using the before_channel_entry_save hook. In the EE documentation it says and modifications to the object will be saved. I am doing something like this but no matter what I do my modifications do not get saved. Ideas?
public function set_custom_fields($entry, $values)
{
$customFields = $entry->getCustomFields();
foreach ($customFields as $field) {
if (strpos($field->getShortName() === "my_custom_field_name") {
// I have tried just and also with the line below
$field->setData('my custom value');
// I have tried just and also with the line above
$values[$field->getShortName()] = 'my custom value';
}
}
}
If I dump the values after this I see that my custom field value has indeed been updated but it is not saved the database.