Answers.Body: <p>The problem was that there were validation failures that were silently failing. The mighty Brad's suggestion of <code>$entry-&gt;getErrors() after calling saveEntry()</code> let me see what the issue was.</p>
  
  <p>Thanks Brad!</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-01-11T08:57:35.897Z
Answers.LastActivityDate: 2017-01-11T08:57:35.897Z
Answers.UserDisplayName: John
Answers.Body: <p>I haven't used <code>getEntryById</code>, and this isn't exactly an answer, but here is how I am doing pretty much the same thing:</p>
  
  <pre><code>$criteria = craft()-&gt;elements-&gt;getCriteria(ElementType::Entry);
  $criteria-&gt;section = 'mySection');
  $criteria-&gt;status = null;
  $criteria-&gt;limit = 1;
  $entry = $criteria-&gt;first();
  
  ...
  if ($entry) {
      $entry-&gt;setContentFromPost([
          'myFieldHandle' =&gt; 'woot'
      ]);
  
      craft()-&gt;entries-&gt;saveEntry($entry);
  } else {
      // Could not find entry.
  }
  
  ...
  </code></pre>
  
  <p>Unless you are setting the page title, then I think you need to use something like:</p>
  
  <pre><code>...
  $entry-&gt;getContent()-&gt;title = 'woot';
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-01-11T04:04:11.090Z
Answers.LastActivityDate: 2017-01-11T04:04:11.090Z
Answers.UserDisplayName: Damon
Body: <p>So, i'm trying to set a fields content via a plugin on an entry which already exists.</p>
  
  <p>My code is like this:</p>
  
  <pre><code>$entry = craft()-&gt;entries-&gt;getEntryById($entryId);
  
  $entry-&gt;setContentFromPost(array(
      'subTitle' =&gt; 'woot'
  ));
  
  $success = craft()-&gt;entries-&gt;saveEntry($entry);
  </code></pre>
  
  <p>I get no error and the value of <code>$success</code> is <code>false</code> but it tells me nothing else.
  If I <code>var_dump($entry)</code> after the first line, the output shows it has pulled the correct entry.</p>
  
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2017-01-10T16:41:41.997Z
Comments.Text: I think `setContentFromPost` might be intended for when using forms with `$_POST` data (there are some underlying functions that trigger when using this method) . Have you tried just `$entry->setContent(array())`?
Comments.UserDisplayName: Alec Ritson
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2017-01-10T22:09:56.197Z
Comments.Text: I tried this: ```$entry->getContent()->subTitle = "woot"``` but didn't try set content! Thanks!
Comments.UserDisplayName: John
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2017-01-11T03:41:00.223Z
Comments.Text: Do you get anything if you call `$entry->getErrors()` after calling `saveEntry()`?
Comments.UserDisplayName: Brad Bell
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2017-01-11T08:56:18.290Z
Comments.Text: @BradBell Aha! There are validation errors, clearly some fields have been made required after the initial entry was saved. Thanks very much Brad!!!
Comments.UserDisplayName: John
Tags: <plugin-development>
Title: Update existing entry from plugin not saving and producing no error
ThreadText: # Update existing entry from plugin not saving and producing no error
  
  (Asked by: username_0 on 2017-01-10)
  
  So, i'm trying to set a fields content via a plugin on an entry which already exists.
  
  My code is like this:
  
  ```
  $entry = craft()->entries->getEntryById($entryId);
  
  $entry->setContentFromPost(array(
      'subTitle' => 'woot'
  ));
  
  $success = craft()->entries->saveEntry($entry);
  
  ```
  
  I get no error and the value of `$success` is `false` but it tells me nothing else.
  If I `var_dump($entry)` after the first line, the output shows it has pulled the correct entry.
  
  **Tags:** plugin-development
  
  > **Comments:**
  > **username_1**: I think `setContentFromPost` might be intended for when using forms with `$_POST` data (there are some underlying functions that trigger when using this method) . Have you tried just `$entry->setContent(array())`?  
  > **username_0**: I tried this: ```$entry->getContent()->subTitle = "woot"``` but didn't try set content! Thanks!  
  > **username_2**: Do you get anything if you call `$entry->getErrors()` after calling `saveEntry()`?  
  > **username_0**: @username_2 Aha! There are validation errors, clearly some fields have been made required after the initial entry was saved. Thanks very much username_2!!!  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_0 on 2017-01-11. Score: 1
  
  The problem was that there were validation failures that were silently failing. The mighty username_2's suggestion of `$entry->getErrors() after calling saveEntry()` let me see what the issue was.
  
  Thanks username_2!
  
  
  ---
  
  ### Answer by username_3 on 2017-01-11. Score: 1
  
  I haven't used `getEntryById`, and this isn't exactly an answer, but here is how I am doing pretty much the same thing:
  
  ```
  $criteria = craft()->elements->getCriteria(ElementType::Entry);
  $criteria->section = 'mySection');
  $criteria->status = null;
  $criteria->limit = 1;
  $entry = $criteria->first();
  
  ...
  if ($entry) {
      $entry->setContentFromPost([
          'myFieldHandle' => 'woot'
      ]);
  
      craft()->entries->saveEntry($entry);
  } else {
      // Could not find entry.
  }
  
  ...
  
  ```
  
  Unless you are setting the page title, then I think you need to use something like:
  
  ```
  ...
  $entry->getContent()->title = 'woot';
  
  ```
  
  
  ---
  
  