Answers.Body: <p>If you want to update an already existing entry then you should add a hidden field for the entryId like below:</p>
  <pre><code>{{ hiddenInput('entryId', idOfTheExistingEntry) }}
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-02-20T18:49:32.760Z
Answers.Text: Yep, that would work if i had the id of the existing entry, but I'm trying to match the entry based on the title field
Answers.UserDisplayName: Clay Kilby
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-02-21T19:37:12.497Z
Answers.Text: @ClayKilby Where does your “entry” variable come from, in the example above?
Answers.UserDisplayName: Mats Mikkel Rummelhoff
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-02-21T20:32:53.230Z
Answers.Text: @MatsMikkelRummelhoff that is the entry for the page this form appears on, which is not related to the entry it is saving to
Answers.UserDisplayName: Clay Kilby
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-02-20T11:12:16.393Z
Answers.LastActivityDate: 2022-02-20T11:12:16.393Z
Answers.UserDisplayName: Jay V
Answers.Body: <p>What you're trying to achieve is not possible to do using the stock <a href="https://github.com/craftcms/cms/blob/develop/src/controllers/EntriesController.php#L311" rel="nofollow noreferrer"><code>entries/save-entry</code></a> controller action.</p>
  <p>You'll likely need to <a href="https://craftcms.com/docs/3.x/extend/module-guide.html" rel="nofollow noreferrer">create a custom module</a> with a custom <a href="https://craftcms.com/docs/3.x/extend/controllers.html" rel="nofollow noreferrer">controller action</a> containing the logic required to</p>
  <ol>
  <li>match the given title to an existing entry</li>
  <li>set new field values from the form to the entry</li>
  <li>re-save the entry</li>
  <li>redirect</li>
  </ol>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-02-22T11:17:53.393Z
Answers.LastActivityDate: 2022-02-22T13:25:01.567Z
Answers.LastEditDate: 2022-02-22T13:25:01.567Z
Answers.UserDisplayName: Mats Mikkel Rummelhoff
Body: <p>I'm building a Craft CMS entry form like the one at: <a href="https://craftcms.com/knowledge-base/entry-form" rel="nofollow noreferrer">https://craftcms.com/knowledge-base/entry-form</a> . It needs to update existing entries within the section when their titles match, but should never create a new entry. Right now it's creating new entries only. Code is:</p>
  <pre><code>{% macro errorList(errors) %}
    {% if errors %}
      {{ ul(errors, {class: 'errors'}) }}
    {% endif %}
  {% endmacro %}
  
  {% set entry = entry ?? create('craft\\elements\\Entry') %}
  
  &lt;form method=&quot;post&quot; accept-charset=&quot;UTF-8&quot;&gt;
    {{ csrfInput() }}
    {{ actionInput('entries/save-entry') }}
    {{ redirectInput(entry.formRedirect.one.url) }}
    {{ hiddenInput('sectionId', '10') }}
  
    &lt;div class=&quot;form-floating mb-3&quot;&gt;
      &lt;input type=&quot;email&quot; id=&quot;title&quot; class=&quot;form-control&quot; name=&quot;title&quot; placeholder=&quot;Email Address&quot;&gt;
      &lt;label for=&quot;title&quot;&gt;Email Address&lt;/label&gt;
    &lt;/div&gt;
  
    &lt;input style=&quot;display:none;&quot; type=&quot;date&quot; id=&quot;currentAccessStartDate&quot; name=&quot;fields[currentAccessStartDate]&quot; value=&quot;{{ now|date('Y-m-d') }}&quot;&gt;
    &lt;input style=&quot;display:none;&quot; type=&quot;checkbox&quot; id=&quot;sendEmailOnSave&quot; name=&quot;fields[sendEmailOnSave]&quot; value=&quot;1&quot; checked=&quot;true&quot;&gt;
    &lt;button type=&quot;submit&quot; class=&quot;btn-std&quot;&gt;{{ entry.formButtonLabel }}&lt;/button&gt;
  &lt;/form&gt;
  </code></pre>
  <p>I've also tried doing this with the Formie plugin from Verbb, which works well for updating existing entries, but doesn't seem to have any way to prevent it from creating new ones.</p>
  
Tags: <entry-form>
Title: Craft CMS Entry Form Update Existing Entries without Creating New Ones
ThreadText: # Craft CMS Entry Form Update Existing Entries without Creating New Ones
  
  (Asked by: username_0 on 2022-02-20)
  
  I'm building a Craft CMS entry form like the one at: <https://craftcms.com/knowledge-base/entry-form> . It needs to update existing entries within the section when their titles match, but should never create a new entry. Right now it's creating new entries only. Code is:
  
  ```
  {% macro errorList(errors) %}
    {% if errors %}
      {{ ul(errors, {class: 'errors'}) }}
    {% endif %}
  {% endmacro %}
  
  {% set entry = entry ?? create('craft\\elements\\Entry') %}
  
  <form method="post" accept-charset="UTF-8">
    {{ csrfInput() }}
    {{ actionInput('entries/save-entry') }}
    {{ redirectInput(entry.formRedirect.one.url) }}
    {{ hiddenInput('sectionId', '10') }}
  
    <div class="form-floating mb-3">
      <input type="email" id="title" class="form-control" name="title" placeholder="Email Address">
      <label for="title">Email Address</label>
    </div>
  
    <input style="display:none;" type="date" id="currentAccessStartDate" name="fields[currentAccessStartDate]" value="{{ now|date('Y-m-d') }}">
    <input style="display:none;" type="checkbox" id="sendEmailOnSave" name="fields[sendEmailOnSave]" value="1" checked="true">
    <button type="submit" class="btn-std">{{ entry.formButtonLabel }}</button>
  </form>
  
  ```
  
  I've also tried doing this with the Formie plugin from Verbb, which works well for updating existing entries, but doesn't seem to have any way to prevent it from creating new ones.
  
  **Tags:** entry-form
  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_1 on 2022-02-20. Score: 2
  
  If you want to update an already existing entry then you should add a hidden field for the entryId like below:
  
  ```
  {{ hiddenInput('entryId', idOfTheExistingEntry) }}
  
  ```
  
  > **Comments:**
  > **username_0**: Yep, that would work if i had the id of the existing entry, but I'm trying to match the entry based on the title field  
  > **username_2**: @username_0 Where does your “entry” variable come from, in the example above?  
  > **username_0**: @username_2 that is the entry for the page this form appears on, which is not related to the entry it is saving to  
  
  ---
  
  ### Answer by username_2 on 2022-02-22. Score: 0
  
  What you're trying to achieve is not possible to do using the stock [`entries/save-entry`](https://github.com/craftcms/cms/blob/develop/src/controllers/EntriesController.php#L311) controller action.
  
  You'll likely need to [create a custom module](https://craftcms.com/docs/3.x/extend/module-guide.html) with a custom [controller action](https://craftcms.com/docs/3.x/extend/controllers.html) containing the logic required to
  
  1. match the given title to an existing entry
  2. set new field values from the form to the entry
  3. re-save the entry
  4. redirect
  
  
  ---
  
  