Answers.Body: <p>I reached out to the Pixel and Tonic support and pointed them to this question. I added, that I want to be able to create drafts for existing entries but also for new entries.</p>
  <p>Here is the answer:</p>
  <blockquote>
  <p>There a three endpoint you will need:</p>
  <pre><code>entries/save-entry
  elements/save-draft
  elements/apply-draft
  </code></pre>
  <p>The first is kind of obvious :)</p>
  <p>The second is the one you would use to create/save the draft of an
  entry, meaning, you'll need to pass it an elementId which is the id of
  the entry you want to create a draft for.</p>
  <p>The last one is the one you would use to apply the draft to the main
  entry. This one will need a elementId and draftId.</p>
  <p>Now, I'm sure you can see the difficulty with creating only a draft as
  a draft requires an entry first.</p>
  </blockquote>
  <p>Note, the needed param for the second and third action is <code>elementId</code> (not <code>entryId</code> as needed for the first action).</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2024-10-16T09:47:29.507Z
Answers.LastActivityDate: 2024-10-16T16:45:38.530Z
Answers.LastEditDate: 2024-10-16T16:45:38.530Z
Answers.UserDisplayName: obs
Body: <p>I'm trying to build a front end form which creates entries. So far, this works great when using <code>actionInput('entries/save-entry')</code>.</p>
  <p>I also want to provide the option to save the entry as a draft. I found, that I need to change the actionInput to <code>actionInput('entry-revisions/save-draft')</code>.
  Unfortunately, this doesn't work. It gives me a 404 error:</p>
  <blockquote>
  <p>HTTP 404 – Not Found – yii\web\NotFoundHttpException</p>
  <p>Caused by: Invalid Route – yii\base\InvalidRouteException Unable to
  resolve the request &quot;entry-revisions/save-draft&quot;.</p>
  <p>in /var/www/html/vendor/yiisoft/yii2/base/Module.php at line 561</p>
  </blockquote>
  <p>I assume it changed with Craft Version 5, but I can't find any hints what needs to be changed for this to work.</p>
  <p>I found the &quot;Controller Actions&quot; page in the docs: <a href="https://craftcms.com/docs/5.x/reference/controller-actions.html" rel="nofollow noreferrer">https://craftcms.com/docs/5.x/reference/controller-actions.html</a></p>
  <p>This let me to the Class Reference for Entry Controllers: <a href="https://docs.craftcms.com/api/v5/craft-controllers-entriescontroller.html#public-methods" rel="nofollow noreferrer">https://docs.craftcms.com/api/v5/craft-controllers-entriescontroller.html#public-methods</a></p>
  <p>Looking (and searching) through several pages there, I couldn't find any hints about how to save a draft.
  Can anyone help me out here?</p>
  
Tags: <frontend-form><craft5><draft><action>
Title: Save draft via front end form
ThreadText: # Save draft via front end form
  
  (Asked by: username_0 on 2024-10-07)
  
  I'm trying to build a front end form which creates entries. So far, this works great when using `actionInput('entries/save-entry')`.
  
  I also want to provide the option to save the entry as a draft. I found, that I need to change the actionInput to `actionInput('entry-revisions/save-draft')`.
  Unfortunately, this doesn't work. It gives me a 404 error:
  
  > HTTP 404 – Not Found – yii\web\NotFoundHttpException
  >
  > Caused by: Invalid Route – yii\base\InvalidRouteException Unable to
  > resolve the request "entry-revisions/save-draft".
  >
  > in /var/www/html/vendor/yiisoft/yii2/base/Module.php at line 561
  
  I assume it changed with Craft Version 5, but I can't find any hints what needs to be changed for this to work.
  
  I found the "Controller Actions" page in the docs: <https://craftcms.com/docs/5.x/reference/controller-actions.html>
  
  This let me to the Class Reference for Entry Controllers: <https://docs.craftcms.com/api/v5/craft-controllers-entriescontroller.html#public-methods>
  
  Looking (and searching) through several pages there, I couldn't find any hints about how to save a draft.
  Can anyone help me out here?
  
  **Tags:** frontend-form, craft5, draft, action
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_0 on 2024-10-16. Score: 0 | Accepted answer
  
  I reached out to the Pixel and Tonic support and pointed them to this question. I added, that I want to be able to create drafts for existing entries but also for new entries.
  
  Here is the answer:
  
  > There a three endpoint you will need:
  >
  > ```
  > entries/save-entry
  > elements/save-draft
  > elements/apply-draft
  >
  > ```
  >
  > The first is kind of obvious :)
  >
  > The second is the one you would use to create/save the draft of an
  > entry, meaning, you'll need to pass it an elementId which is the id of
  > the entry you want to create a draft for.
  >
  > The last one is the one you would use to apply the draft to the main
  > entry. This one will need a elementId and draftId.
  >
  > Now, I'm sure you can see the difficulty with creating only a draft as
  > a draft requires an entry first.
  
  Note, the needed param for the second and third action is `elementId` (not `entryId` as needed for the first action).
  
  
  ---
  
  