Answers.Body: <p>As far as I'm aware, there is no way to explicitly disable a custom field once it has a value.</p>
  <p>You could prevent data for that field from being submitted on the front end by only providing the input for <code>myFieldHandle</code> if it does not have a value:</p>
  <pre><code>{% if not entry.myFieldHandle.exists() %}
    &lt;input type=&quot;text&quot; name=&quot;fields[myFieldHandle][]&quot; value=&quot;{{ currentUser.id }}&quot; hidden&gt;
  {% endif %}
  </code></pre>
  <p>If <code>myFieldHandle</code> already has a user associated with it, the field will not be provided on the front-end, thus the field cannot be changed.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-10-14T16:14:58.967Z
Answers.Text: Thanks for your reply. I thought about that as well but I need to be 100% sure the field cannot be overwritten. Even if 2 users submit the form at the same time without reloading the website in between.
Answers.UserDisplayName: jlg1807
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-10-07T15:23:32.917Z
Answers.LastActivityDate: 2022-10-07T15:23:32.917Z
Answers.UserDisplayName: Kirk P.
Body: <p>I have a frontend form that updates a single entry and sets the users field to the current user:</p>
  <pre><code>&lt;form method=&quot;post&quot; accept-charset=&quot;UTF-8&quot;&gt;
      {{ csrfInput() }}
      {{ actionInput('entries/save-entry') }}
      {{ redirectInput('') }}
      {{ hiddenInput('sectionId', '1') }}
      {{ hiddenInput('entryId', entry.id) }}
      {{ hiddenInput('enabled', '1') }}
      
      &lt;input type=&quot;text&quot; name=&quot;fields[myFieldHandle][]&quot; value=&quot;{{ currentUser.id }}&quot; hidden&gt;
      &lt;button type=&quot;submit&quot;&gt;Save&lt;/button&gt;
      
  &lt;/form&gt;
  </code></pre>
  <p>Let's assume that the users field is empty and user1 submits the form. The users field will be set to user1. If user2 submits the form after that, the users field will be set to user2.</p>
  <p><strong>User2 should not be able to update the users field, because its value is already set to user1.</strong></p>
  <p>I don't really know how to achieve this since you cannot simply add a user to a users field without overwriting existing values. I could disable the form for user2 in the frontend but that doesn't solve the problem.</p>
  
Tags: <users><form><frontend><entries-field>
Title: Add entry to entry field via frontend form
ThreadText: # Add entry to entry field via frontend form
  
  (Asked by: username_0 on 2022-10-07)
  
  I have a frontend form that updates a single entry and sets the users field to the current user:
  
  ```
  <form method="post" accept-charset="UTF-8">
      {{ csrfInput() }}
      {{ actionInput('entries/save-entry') }}
      {{ redirectInput('') }}
      {{ hiddenInput('sectionId', '1') }}
      {{ hiddenInput('entryId', entry.id) }}
      {{ hiddenInput('enabled', '1') }}
      
      <input type="text" name="fields[myFieldHandle][]" value="{{ currentUser.id }}" hidden>
      <button type="submit">Save</button>
      
  </form>
  
  ```
  
  Let's assume that the users field is empty and user1 submits the form. The users field will be set to user1. If user2 submits the form after that, the users field will be set to user2.
  
  **User2 should not be able to update the users field, because its value is already set to user1.**
  
  I don't really know how to achieve this since you cannot simply add a user to a users field without overwriting existing values. I could disable the form for user2 in the frontend but that doesn't solve the problem.
  
  **Tags:** users, form, frontend, entries-field
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2022-10-07. Score: 1
  
  As far as I'm aware, there is no way to explicitly disable a custom field once it has a value.
  
  You could prevent data for that field from being submitted on the front end by only providing the input for `myFieldHandle` if it does not have a value:
  
  ```
  {% if not entry.myFieldHandle.exists() %}
    <input type="text" name="fields[myFieldHandle][]" value="{{ currentUser.id }}" hidden>
  {% endif %}
  
  ```
  
  If `myFieldHandle` already has a user associated with it, the field will not be provided on the front-end, thus the field cannot be changed.
  
  > **Comments:**
  > **username_0**: Thanks for your reply. I thought about that as well but I need to be 100% sure the field cannot be overwritten. Even if 2 users submit the form at the same time without reloading the website in between.  
  
  ---
  
  