Answers.Body: <p>This will return the content for the specific element instance you're on:</p>
  
  <pre><code>$this-&gt;element-&gt;getContent()
  </code></pre>
  
  <p>And from there you can do your additional content processing.</p>
  
  <p>When you're ready so save it, you can call:</p>
  
  <pre><code>craft()-&gt;content-&gt;saveContent($this-&gt;element);
  </code></pre>
  
  <p>There are several examples in <code>craft/app/fieldtypes</code> folder where Craft's native field types do additional processing like this.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-08-13T21:41:15.810Z
Answers.Text: So if I update a property on the `ContentModel`, how does that data get saved to the db? When I update my property, the new data isn't saved to the db and you can't call `save()` on models.
Answers.UserDisplayName: Justin Kimbrell
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-08-13T21:58:14.173Z
Answers.Text: I figured it out. I just ran the following code to save the content. `craft()->content->saveContent($this->element);` If there is a better way, let me know. If not, may be helpful to update your answer with that code and I'll mark it as correct.
Answers.UserDisplayName: Justin Kimbrell
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-08-13T22:09:21.950Z
Answers.Text: That's the way... updated!
Answers.UserDisplayName: Brad Bell
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-08-13T21:14:51.087Z
Answers.LastActivityDate: 2014-08-13T22:08:50.430Z
Answers.LastEditDate: 2014-08-13T22:08:50.430Z
Answers.UserDisplayName: Brad Bell
Body: <p>I am building a field type for Craft that needs to do additional processing to the saved data once the element id is available. For this reason, the <code>prepValueFromPost()</code> method won't work, since the element id isn't available yet.</p>
  
  <p>So how to update the content of the current element from the <code>onAfterElementSave()</code> method?</p>
  
Tags: <plugin-development><custom-fieldtype>
Title: How do I update the content of a field type in the onAfterElementSave() method?
ThreadText: # How do I update the content of a field type in the onAfterElementSave() method?
  
  (Asked by: username_0 on 2014-08-13)
  
  I am building a field type for Craft that needs to do additional processing to the saved data once the element id is available. For this reason, the `prepValueFromPost()` method won't work, since the element id isn't available yet.
  
  So how to update the content of the current element from the `onAfterElementSave()` method?
  
  **Tags:** plugin-development, custom-fieldtype
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2014-08-13. Score: 4 | Accepted answer
  
  This will return the content for the specific element instance you're on:
  
  ```
  $this->element->getContent()
  
  ```
  
  And from there you can do your additional content processing.
  
  When you're ready so save it, you can call:
  
  ```
  craft()->content->saveContent($this->element);
  
  ```
  
  There are several examples in `craft/app/fieldtypes` folder where Craft's native field types do additional processing like this.
  
  > **Comments:**
  > **username_0**: So if I update a property on the `ContentModel`, how does that data get saved to the db? When I update my property, the new data isn't saved to the db and you can't call `save()` on models.  
  > **username_0**: I figured it out. I just ran the following code to save the content. `craft()->content->saveContent($this->element);` If there is a better way, let me know. If not, may be helpful to update your answer with that code and I'll mark it as correct.  
  > **username_1**: That's the way... updated!  
  
  ---
  
  