Answers.Body: <p>Actually, onAfterElementSave doesn't get called at all when saving a draft, so there's nothing to worry about.</p>
  
  <p>When you load a draft in the CP, your field type will be passed in a $value based on the POST data for the field back when the draft was last saved (which is the same thing that happens when saving an entry fails due to validation errors).</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-10-23T16:25:00.183Z
Answers.Text: For some reason that method is being called in my plugin when I save the entry as a draft. I am using "Craft Pro 2.2.2596".
Answers.UserDisplayName: a-am
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-10-24T12:23:10.820Z
Answers.Text: @aran Is that for a brand new entry? In that case it will get called, but it won't matter because the entry will be disabled and there's no chance you'll be overwriting existing data for the entry.
Answers.UserDisplayName: Brandon Kelly
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-10-23T16:16:39.307Z
Answers.LastActivityDate: 2014-10-23T16:16:39.307Z
Answers.UserDisplayName: Brandon Kelly
Body: <p>Is there a way to detect if a entry is being saved as a draft vs being published so when onAfterElementSave is called, so I don't save data to the database when it is a draft.</p>
  
Tags: <plugin-development>
Title: When onAfterElementSave is called check for save as draft or publishing?
ThreadText: # When onAfterElementSave is called check for save as draft or publishing?
  
  (Asked by: username_0 on 2014-10-23)
  
  Is there a way to detect if a entry is being saved as a draft vs being published so when onAfterElementSave is called, so I don't save data to the database when it is a draft.
  
  **Tags:** plugin-development
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2014-10-23. Score: 1 | Accepted answer
  
  Actually, onAfterElementSave doesn't get called at all when saving a draft, so there's nothing to worry about.
  
  When you load a draft in the CP, your field type will be passed in a $value based on the POST data for the field back when the draft was last saved (which is the same thing that happens when saving an entry fails due to validation errors).
  
  > **Comments:**
  > **username_0**: For some reason that method is being called in my plugin when I save the entry as a draft. I am using "Craft Pro 2.2.2596".  
  > **username_1**: @aran Is that for a brand new entry? In that case it will get called, but it won't matter because the entry will be disabled and there's no chance you'll be overwriting existing data for the entry.  
  
  ---
  
  