Answers.Body: <p>After talking to Craft Support (Thanks Oli!), the solution for Craft 3 is...</p>
  <pre><code>{{ hiddenInput('fields[vendorLocations][sortOrder][]', 'new:1') }}
  
  {{ hiddenInput('fields[vendorLocations][blocks][new:1][type]', 'address') }}
  
  
  &lt;select name=&quot;fields[vendorLocations][blocks][new:1][fields][city]&quot; required&gt;
     &lt;option value=&quot;&quot;&gt;Choose One&lt;/option&gt;
     {% for city in riCities() %}
       &lt;option value=&quot;{{ city|title }}&quot;&gt;{{ city|title }}&lt;/option&gt;
     {% endfor %}
  &lt;/select&gt;
  </code></pre>
  <p>Make sure the proper entryTypeId, section etc. is defined for your form as well, this is just the specifics for the new matrix block.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-09-21T19:54:50.820Z
Answers.LastActivityDate: 2022-09-21T19:54:50.820Z
Answers.UserDisplayName: cherrykoda
Body: <p>Referencing <a href="https://craftcms.com/docs/3.x/matrix-fields.html#saving-matrix-fields" rel="nofollow noreferrer">https://craftcms.com/docs/3.x/matrix-fields.html#saving-matrix-fields</a> I believe I did this correctly according to the docs and other posts here. My Matrix field is able to save edits, but when the field is empty adding a new block does NOT work.</p>
  <p>POST data from the form submission:</p>
  <p><a href="https://i.sstatic.net/awA7D.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/awA7D.png" alt="enter image description here" /></a></p>
  <p>Code:</p>
  <pre><code>{{ hiddenInput('fields[vendorLocations][blocks][new1][type]', 'address') }}
  {{ hiddenInput('fields[vendorLocations][blocks][new1][enabled]', '1') }}
  &lt;select name=&quot;fields[vendorLocations][blocks][new1][fields][city]&quot; required&gt;
     &lt;option value=&quot;&quot;&gt;Choose One&lt;/option&gt;
     {% for city in riCities() %}
       &lt;option value=&quot;{{ city|title }}&quot;&gt;{{ city|title }}&lt;/option&gt;
     {% endfor %}
  &lt;/select&gt;
  </code></pre>
  <p>Desired CMS Result:</p>
  <p><a href="https://i.sstatic.net/bOhaP.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/bOhaP.png" alt="enter image description here" /></a></p>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2022-09-20T01:49:16.463Z
Comments.Text: try to remove [blocks].
Comments.UserDisplayName: aodihis
Tags: <craft3><matrix><frontend-form>
Title: Adding New Matrix Block via Frontend in Craft 3
ThreadText: # Adding New Matrix Block via Frontend in Craft 3
  
  (Asked by: username_0 on 2022-09-18)
  
  Referencing <https://craftcms.com/docs/3.x/matrix-fields.html#saving-matrix-fields> I believe I did this correctly according to the docs and other posts here. My Matrix field is able to save edits, but when the field is empty adding a new block does NOT work.
  
  POST data from the form submission:
  
  [![enter image description here](https://i.sstatic.net/awA7D.png)](https://i.sstatic.net/awA7D.png)
  
  Code:
  
  ```
  {{ hiddenInput('fields[vendorLocations][blocks][new1][type]', 'address') }}
  {{ hiddenInput('fields[vendorLocations][blocks][new1][enabled]', '1') }}
  <select name="fields[vendorLocations][blocks][new1][fields][city]" required>
     <option value="">Choose One</option>
     {% for city in riCities() %}
       <option value="{{ city|title }}">{{ city|title }}</option>
     {% endfor %}
  </select>
  
  ```
  
  Desired CMS Result:
  
  [![enter image description here](https://i.sstatic.net/bOhaP.png)](https://i.sstatic.net/bOhaP.png)
  
  **Tags:** craft3, matrix, frontend-form
  
  > **Comments:**
  > **username_1**: try to remove [blocks].  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_0 on 2022-09-21. Score: 5 | Accepted answer
  
  After talking to Craft Support (Thanks Oli!), the solution for Craft 3 is...
  
  ```
  {{ hiddenInput('fields[vendorLocations][sortOrder][]', 'new:1') }}
  
  {{ hiddenInput('fields[vendorLocations][blocks][new:1][type]', 'address') }}
  
  <select name="fields[vendorLocations][blocks][new:1][fields][city]" required>
     <option value="">Choose One</option>
     {% for city in riCities() %}
       <option value="{{ city|title }}">{{ city|title }}</option>
     {% endfor %}
  </select>
  
  ```
  
  Make sure the proper entryTypeId, section etc. is defined for your form as well, this is just the specifics for the new matrix block.
  
  
  ---
  
  