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());

                    'aantalAanvragen' => $total


This for example $form->setAttribute('slug', "testtestetst"); won't work. Is there something i am missing here?


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.

  • 1
    Spot on, i get it to work with the first method of Brandon here craftcms.stackexchange.com/questions/4485/… getting the value first and then resaving it again..thanks – Jacob Apr 21 '16 at 8:13
  • That method is not nice, I agree, but it's currently necessary. Fortunatelly Craft 3 will improve on it (if it's true what I heard). – carlcs Apr 21 '16 at 9:52