I am trying to change custom field values of a existing entry, but it won't save them in the database. It saves it on the model but the entry isn't persisted to the database.
craft()->on('guestEntries.success', function(GuestEntriesEvent $event) {
if (!$event->fakeIt)
{
$entryModel = $event->params['entry'];
if ($entryModel->section->handle == "aanvragen")
{
$form = $entryModel->formulier->first();
if ($form)
{
// get all entries with that form
$criteria = craft()->elements->getCriteria(ElementType::Entry);
$criteria->section = "aanvragen";
$criteria->relatedTo = array(
'targetElement' => $form
);
$total = strval($criteria->total());
$form->getContent()->setAttributes(array(
'aantalAanvragen' => $total
));
craft()->entries->saveEntry($form);
}
}
}
}
This for example $form->setAttribute('slug', "testtestetst"); won't work.
Is there something i am missing here?
EDIT:
It seems that it was sticking on entry validation upon saving. There are some fields required. However these fields are already filled in, in the CP, i just want to update one field on a EntryModel is there a way to just do this.