I have a task that is used to collate relationship data for a specific entry and save it as JSON to a text field in that entry. Everything is working fine, except for the saving of the entry which fails because the required Matrix / Assets fields in the entry are being read as blank. I've checked to make sure that the entries have all required fields completed, but the errors still persist.
The entry saving code in the task:
$entry->getContent()->setAttribute('latLngs', json_encode($latLngs));
craft()->entries->saveEntry($entry);
The errors being returned:
[_errors:CModel:private] => Array
(
[gallery] => Array
(
[0] => Gallery cannot be blank.
)
[standardContent] => Array
(
[0] => Standard Content cannot be blank.
)
)
Where gallery
is an Assets field, and standardContent
is a Matrix field. All other required fields seem to be working fine with no errors.
Is this to do with the way I'm saving the entries, or something else?
Thanks!