<p>Getting a Matrix field working on the front-end is going to require 2 things:</p>

<ol>
<li>Setting up the field inputs so the data submits correctly.</li>
<li>Some custom JavaScript to make the blocks repeat and behave how you want them to.</li>
</ol>

<p>Here's an example of the Matrix input code you'll need on the front-end.  You'll need to update all of the field handle values to fit your situation:</p>

<pre><code>{# You need to include the 'type' input to identify the matrix block type you are submitting. #}
&lt;input type="hidden" name="fields[contact][new1][type]" value="contacts"&gt;

{# You should include the 'enabled' input to specify whether the block should be enabled. #}
&lt;input type="hidden" name="fields[contact][new1][enabled]" value="1"&gt;

{# All of your custom fields must be within a 'fields' array. #}
&lt;input type="text" name="fields[contact][new1][fields][contactName]"&gt;
&lt;input type="text" name="fields[contact][new1][fields][contactEmail]"&gt;
&lt;input type="text" name="fields[contact][new1][fields][contactPhone]"&gt;

{# For new blocks, you'll want to use the naming convention 'new1', 'new2', 'new3' for each of your blocks. For existing blocks, you can update those values to be the block IDs. #}
&lt;input type="text" name="fields[contact][new2][fields][contactName]"&gt;
&lt;input type="text" name="fields[contact][new2][fields][contactEmail]"&gt;
&lt;input type="text" name="fields[contact][new2][fields][contactPhone]"&gt;
</code></pre>

<p>As for the JavaScript, I won't give an example here, but you'll want to create a way for users to create new blocks, update the ID value appropriately using the <code>new1</code> convention for new entries and the actual IDs for entries that are being edited.</p>

CC BY-SA 3.0
2014-07-22T15:32:49.360Z
2017-01-27T06:52:39.387Z
2017-01-27T06:52:39.387Z
Ben Parizek
<p>I've currently setup a matrix-field for adresses. I added the field as required field to my user-group "Customer". Which breaks the registration, as a user can only be registered, when the matrix has at last one entry.</p>

<p>What im missing now is the possibility to add the specific input elements for one single address-block (or matrix entry) so the user has to add at last one address at registration.</p>

<p>When logged in and viewing the profile, the user should also be able to manage  his matrix entries, so managing multiple addresses.</p>

<p>Is there any documentation on how to get the backend-matrix-editor into the frontend? Can anyone link me an example without copying the whole backend stuff into the frontend?</p>

<matrix><editor>
How to get matrix editor into frontend?
# How to get matrix editor into frontend?

(Asked by: username_0 on 2014-07-22)

I've currently setup a matrix-field for adresses. I added the field as required field to my user-group "Customer". Which breaks the registration, as a user can only be registered, when the matrix has at last one entry.

What im missing now is the possibility to add the specific input elements for one single address-block (or matrix entry) so the user has to add at last one address at registration.

When logged in and viewing the profile, the user should also be able to manage his matrix entries, so managing multiple addresses.

Is there any documentation on how to get the backend-matrix-editor into the frontend? Can anyone link me an example without copying the whole backend stuff into the frontend?

**Tags:** matrix, editor

---

## 1 answers

### Answer by username_1 on 2014-07-22. Score: 18 | Accepted answer

Getting a Matrix field working on the front-end is going to require 2 things:

Setting up the field inputs so the data submits correctly.
Some custom JavaScript to make the blocks repeat and behave how you want them to.

Here's an example of the Matrix input code you'll need on the front-end.  You'll need to update all of the field handle values to fit your situation:
{# You need to include the 'type' input to identify the matrix block type you are submitting. #}


{# You should include the 'enabled' input to specify whether the block should be enabled. #}


{# All of your custom fields must be within a 'fields' array. #}




{# For new blocks, you'll want to use the naming convention 'new1', 'new2', 'new3' for each of your blocks. For existing blocks, you can update those values to be the block IDs. #}




As for the JavaScript, I won't give an example here, but you'll want to create a way for users to create new blocks, update the ID value appropriately using the new1 convention for new entries and the actual IDs for entries that are being edited.


---

