<p>Using the example above, here is how you can re-populate the given matrix field(s). The below is assuming only one matrix field is visible by default <code>[0]</code>. Depending on your use case, you may need to dynamically generate the index number.</p>

<pre><code>...
{%- if entry is defined %} value="{{ entry.myMatrixFieldHandle[0].fieldHandle }}"{% endif -%}
...
</code></pre>

CC BY-SA 3.0
2016-03-27T22:36:30.707Z
2016-03-27T23:47:57.583Z
2016-03-27T23:47:57.583Z
Damon
<p>I have a matrix field on my front-end form. Everything is working properly, data is saved correctly etc.</p>

<p>I am testing &amp; trying to break things and I noticed I wasn't repopulating those fields if validation failed.</p>

<p>Here is how I am attempting to repopulate the value(s) in my front-end form:</p>

<pre><code>&lt;input type="hidden" name="fields[myMatrixFieldHandle][new1][type]" value="blockType"&gt;
&lt;input type="hidden" name="fields[myMatrixFieldHandle][new1][enabled]" value="1"&gt;

...
value="{{ entry.myMatrixFieldHandle.blockType.fieldHandle }}"
...
</code></pre>

<p>When I dump the above, I am getting the whole object back. I'm not sure how to get to the actual field's value.</p>

<matrix><user-profile><validation>
How can I repopulate a matrix field on a front-end form?
# How can I repopulate a matrix field on a front-end form?

(Asked by: username_0 on 2016-03-11)

I have a matrix field on my front-end form. Everything is working properly, data is saved correctly etc.
I am testing & trying to break things and I noticed I wasn't repopulating those fields if validation failed.
Here is how I am attempting to repopulate the value(s) in my front-end form:



...
value="{{ entry.myMatrixFieldHandle.blockType.fieldHandle }}"
...

When I dump the above, I am getting the whole object back. I'm not sure how to get to the actual field's value.

**Tags:** matrix, user-profile, validation


---

## 1 answers

### Answer by username_0 on 2016-03-27. Score: 2 | Accepted answer

Using the example above, here is how you can re-populate the given matrix field(s). The below is assuming only one matrix field is visible by default [0]. Depending on your use case, you may need to dynamically generate the index number.
...
{%- if entry is defined %} value="{{ entry.myMatrixFieldHandle[0].fieldHandle }}"{% endif -%}
...


---

