<p>Something on the <code>$entryToSave</code> EntryModel is failing validation.  If you 
echo out <code>implode(', ', $entryToSave()-&gt;getAllErrors());</code>, then you'll see what those errors are and you can correct them.</p>

CC BY-SA 3.0
2015-12-02T22:01:07.860Z
That helped! It was balking on a required field. Just to be clear, if a required field is not explicitly set, even though it was set in existing entry I'm assigning to the entryToSave, I'll still get that error? I resolved it by temporarily setting those fields as not required for the section. Thanks, Brad!
Mark J. Reeves
CC BY-SA 3.0
2015-12-02T19:56:12.813Z
2015-12-02T19:56:12.813Z
Brad Bell
<p>I'm using code I've been using to update existing entries for a while now and it's failing to fire following the 2.5 upgrade. Trying to figure out what might have changed, or if there's something I'm overlooking. I'm consistently getting the "not saved" response and seeing no update in the entry. <code>showInInvestmentAdvisersReference</code> is the new field I'm setting. I've got <code>limit=1</code> set for testing purposes.</p>

<pre><code>$entries = craft()-&gt;elements-&gt;getCriteria(ElementType::Entry);
$entries-&gt;section = 'referenceMaterials';
$entries-&gt;limit = 1;

$existingEntries = $entries-&gt;find();

foreach ($existingEntries as $existingEntry) {
    echo 'id: ' . $existingEntry-&gt;id . '&lt;br /&gt;';

    $entryToSave = new EntryModel();

    $entryToSave = $existingEntry;

    // Setting these in case they're required to be set for saveEntry()
    $entryToSave-&gt;sectionId = 9;
    $entryToSave-&gt;typeId = 9;
    $entryToSave-&gt;authorId = 1;
    $entryToSave-&gt;enabled = true;
    $entryToSave-&gt;getContent()-&gt;title = $existingEntry-&gt;title;

    $entryToSave-&gt;getContent()-&gt;showInInvestmentAdvisersReference = 1;

    if ( craft()-&gt;entries-&gt;saveEntry($entryToSave) )
    {
        echo 'saved&lt;br /&gt;';
    }
    else {
        echo 'not saved&lt;br /&gt;';
    }
}
</code></pre>

<p>Is it me? Did something change? Happy to file a bug report but thought I'd start here first where code formatting is supported.</p>

<plugin-elementapi><services><saveentry>
saveEntry() not firing
# saveEntry() not firing

(Asked by: username_0 on 2015-12-02)

I'm using code I've been using to update existing entries for a while now and it's failing to fire following the 2.5 upgrade. Trying to figure out what might have changed, or if there's something I'm overlooking. I'm consistently getting the "not saved" response and seeing no update in the entry. showInInvestmentAdvisersReference is the new field I'm setting. I've got limit=1 set for testing purposes.
$entries = craft()->elements->getCriteria(ElementType::Entry);
$entries->section = 'referenceMaterials';
$entries->limit = 1;

$existingEntries = $entries->find();

foreach ($existingEntries as $existingEntry) {
    echo 'id: ' . $existingEntry->id . '';

    $entryToSave = new EntryModel();

    $entryToSave = $existingEntry;

    // Setting these in case they're required to be set for saveEntry()
    $entryToSave->sectionId = 9;
    $entryToSave->typeId = 9;
    $entryToSave->authorId = 1;
    $entryToSave->enabled = true;
    $entryToSave->getContent()->title = $existingEntry->title;

    $entryToSave->getContent()->showInInvestmentAdvisersReference = 1;

    if ( craft()->entries->saveEntry($entryToSave) )
    {
        echo 'saved';
    }
    else {
        echo 'not saved';
    }
}

Is it me? Did something change? Happy to file a bug report but thought I'd start here first where code formatting is supported.

**Tags:** plugin-elementapi, services, saveentry

---

## 1 answers

### Answer by username_1 on 2015-12-02. Score: 3 | Accepted answer

Something on the `$entryToSave` EntryModel is failing validation. If you
echo out `implode(', ', $entryToSave()->getAllErrors());`, then you'll see what those errors are and you can correct them.

> **Comments:**
> **username_0**: That helped! It was balking on a required field. Just to be clear, if a required field is not explicitly set, even though it was set in existing entry I'm assigning to the entryToSave, I'll still get that error? I resolved it by temporarily setting those fields as not required for the section. Thanks, Brad!  

---

