Body: <p>I have the following code: </p>
  
  <pre><code>$fieldHandle = 'contentLead';
  
  $entryTitle = $event-&gt;element;
  $entryQuery = \craft\elements\Entry::find();
  
  $entries = $entryQuery-&gt;title($entryTitle)-&gt;limit(1);
  
  foreach ($entries-&gt;all() as $entry) {
      $entry-&gt;setFieldValue($fieldHandle, 'hello');
  
      Craft::$app-&gt;elements-&gt;saveElement($entry, false, true);
  }
  </code></pre>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2019-05-14T03:47:43.170Z
Comments.Text: After saving the element, does `$entry->getErrors()` return anything?
Comments.UserDisplayName: Brad Bell
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2019-09-07T22:10:50.587Z
Comments.Text: Sorry for disappearing, I worked around this issue (forked the Guest Entries plugin). Using the code above in a different case worked perfectly, thanks!
Comments.UserDisplayName: Ottó Radics
Tags: <plugin-development><craft3><plugin-feedme>
Title: Custom field value doesn't get saved
ThreadText: # Custom field value doesn't get saved
  
  (Asked by: username_0 on 2019-05-12)
  
  I have the following code:
  
  ```
  $fieldHandle = 'contentLead';
  
  $entryTitle = $event->element;
  $entryQuery = \craft\elements\Entry::find();
  
  $entries = $entryQuery->title($entryTitle)->limit(1);
  
  foreach ($entries->all() as $entry) {
      $entry->setFieldValue($fieldHandle, 'hello');
  
      Craft::$app->elements->saveElement($entry, false, true);
  }
  
  ```
  
  **Tags:** plugin-development, craft3, plugin-feedme
  
  > **Comments:**
  > **username_1**: After saving the element, does `$entry->getErrors()` return anything?  
  > **username_0**: Sorry for disappearing, I worked around this issue (forked the Guest Entries plugin). Using the code above in a different case worked perfectly, thanks!  
  
  ---
  
  ## 0 answers
  
  