I have a webhook that fetches an entry, modifies one of its custom Text field values and then saves the entry. However there is also a required Categories field on the entry, and when I do this, I get a validation error because the Categories field is blank.
Here’s the relevant code:
$entry = craft()->entries->getEntryById($entryId);
$entry->setContentFromPost(array(
'myTextField' => $newValue
));
// Let's see if it saves.
// Field validation should happen automatically
if (craft()->entries->saveEntry($entry))
{
Craft::log('Entry updated (ID: '.$entry->id.').');
}
else
{
Craft::log('Could not updated the entry (ID: '.$entry->id.').', LogLevel::Error);
}
How do I save the entry without losing its existing Categories field value?