Answers.Body: <p>The default value will only apply to newly created entries. Existing entries won't have any saved value for this field. You're only seeing the first value as selected in your entry edit screen because that's how select fields work (in general, not only in Craft). If no option is selected, the first option is selected automatically. Once you save the entry, the selected value will be saved for that entry.</p>
  <p>To address the comment:</p>
  <blockquote>
  <p>So I think the only solution for old entries is to move my default option at the top of the list right?</p>
  </blockquote>
  <p>This doesn't solve the problem because you would have to save every entry  manually to actually save the selected value. The proper way to add a new field and add a default value to all existing entries is a <a href="https://craftcms.com/docs/3.x/extend/migrations.html" rel="nofollow noreferrer">migration</a>. You can create a new migration using <a href="https://craftcms.com/docs/3.x/console-commands.html#migrate" rel="nofollow noreferrer">console commands</a>:</p>
  <pre><code>php craft migrate/create add_default_field_value
  </code></pre>
  <p>In the migration, you need to find all entries with that field (for example, based on the section it's used in), set the default value for each one and save it.</p>
  <p>For example:</p>
  <pre class="lang-php prettyprint-override"><code>use Craft;
  use craft\elements\Entry;
  
  $entries = Entry::find()-&gt;section('my_section')-&gt;anyStatus()-&gt;all();
  $elementsService = Craft::$app-&gt;getElements();
  foreach ($entries as $entry) {
      $entry-&gt;setFieldValue('my_select_field', 4);
      $elementsService-&gt;saveElement($entry);
  }
  </code></pre>
  <p>Replace <code>my_section</code> and <code>my_select_field</code> with the handles of your section and field, respectively.</p>
  <p>If you have a lot of elements, you might want to <a href="https://www.yiiframework.com/doc/guide/2.0/en/db-query-builder#batch-query" rel="nofollow noreferrer">batch the element query</a> to avoid hitting memory limits.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-12-12T11:50:59.833Z
Answers.LastActivityDate: 2021-12-12T11:50:59.833Z
Answers.UserDisplayName: MoritzLost
Body: <p>maybe this is a weird question but I have a dropdown field with values from 1 to 10, and set 4 as a default value.</p>
  <p>The thing is: I edit my entry and when I see my dropdown the value is number 1, but I set 4 as a default.</p>
  <p><a href="https://i.sstatic.net/pB5AQ.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/pB5AQ.png" alt="enter image description here" /></a></p>
  <p>But if I move the value to the top (above option 1) the value shows in my entry. But this shouldn't be right because there is a default value.
  <a href="https://i.sstatic.net/1c1lb.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/1c1lb.png" alt="enter image description here" /></a></p>
  <p>Do am I missing something?
  Thanks for your help.</p>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2021-12-11T11:05:20.743Z
Comments.Text: Hi, just a simple question, is the field is created after the entries is created? if that so, then yes, the craft will use the first item as the value. but if you create a new entries after the field is created then the default value will be selected by default.
Comments.UserDisplayName: aodihis
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2021-12-11T13:51:41.610Z
Comments.Text: ooh, you're right!! (I have already a lot of entries) That's weird. So I think the only solution for old entries is to move my default option at the top of the list right? Thanks!! @aodihis
Comments.UserDisplayName: suhkha
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2021-12-14T03:20:47.670Z
Comments.Text: Sorry,just read your reply. I don't think so if you move the default is the best way, because if you just do like that, the already created entries is actually don't have the value until you re-save the entries. So the answer by MoritzLost is the best way I think. Or If you don't want to write a code you can try using feed me plugin to update the data.
Comments.UserDisplayName: aodihis
Tags: <entries><field><fieldtypes><entries-field><drop-down>
Title: Field dropdown - default value is not working in CMS
ThreadText: # Field dropdown - default value is not working in CMS
  
  (Asked by: username_0 on 2021-12-11)
  
  maybe this is a weird question but I have a dropdown field with values from 1 to 10, and set 4 as a default value.
  
  The thing is: I edit my entry and when I see my dropdown the value is number 1, but I set 4 as a default.
  
  [![enter image description here](https://i.sstatic.net/pB5AQ.png)](https://i.sstatic.net/pB5AQ.png)
  
  But if I move the value to the top (above option 1) the value shows in my entry. But this shouldn't be right because there is a default value.
  [![enter image description here](https://i.sstatic.net/1c1lb.png)](https://i.sstatic.net/1c1lb.png)
  
  Do am I missing something?
  Thanks for your help.
  
  **Tags:** entries, field, fieldtypes, entries-field, drop-down
  
  > **Comments:**
  > **username_1**: Hi, just a simple question, is the field is created after the entries is created? if that so, then yes, the craft will use the first item as the value. but if you create a new entries after the field is created then the default value will be selected by default.  
  > **username_0**: ooh, you're right!! (I have already a lot of entries) That's weird. So I think the only solution for old entries is to move my default option at the top of the list right? Thanks!! @username_1  
  > **username_1**: Sorry,just read your reply. I don't think so if you move the default is the best way, because if you just do like that, the already created entries is actually don't have the value until you re-save the entries. So the answer by username_2 is the best way I think. Or If you don't want to write a code you can try using feed me plugin to update the data.  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_2 on 2021-12-12. Score: 2
  
  The default value will only apply to newly created entries. Existing entries won't have any saved value for this field. You're only seeing the first value as selected in your entry edit screen because that's how select fields work (in general, not only in Craft). If no option is selected, the first option is selected automatically. Once you save the entry, the selected value will be saved for that entry.
  
  To address the comment:
  
  > So I think the only solution for old entries is to move my default option at the top of the list right?
  
  This doesn't solve the problem because you would have to save every entry manually to actually save the selected value. The proper way to add a new field and add a default value to all existing entries is a [migration](https://craftcms.com/docs/3.x/extend/migrations.html). You can create a new migration using [console commands](https://craftcms.com/docs/3.x/console-commands.html#migrate):
  
  ```
  php craft migrate/create add_default_field_value
  
  ```
  
  In the migration, you need to find all entries with that field (for example, based on the section it's used in), set the default value for each one and save it.
  
  For example:
  
  ```php
  use Craft;
  use craft\elements\Entry;
  
  $entries = Entry::find()->section('my_section')->anyStatus()->all();
  $elementsService = Craft::$app->getElements();
  foreach ($entries as $entry) {
      $entry->setFieldValue('my_select_field', 4);
      $elementsService->saveElement($entry);
  }
  
  ```
  
  Replace `my_section` and `my_select_field` with the handles of your section and field, respectively.
  
  If you have a lot of elements, you might want to [batch the element query](https://www.yiiframework.com/doc/guide/2.0/en/db-query-builder#batch-query) to avoid hitting memory limits.
  
  
  ---
  
  