<p>Turns out it was a validation issue, it works fine when you make the new contact's first+last name mandatory.</p>

CC BY-SA 3.0
2015-01-10T10:50:46.210Z
2015-01-10T10:50:46.210Z
GlennJ
<p>I have used the following code to allow our users to update their own profile. Everything works fine apart from not being able to update existing Matrix entries.</p>

<p>New Matrix field entries work fine. Can anyone spot the mistake I've made?</p>

<pre><code>          &lt;form method="post" accept-charset="UTF-8"&gt;
          {{ getCsrfInput() }}
          &lt;input type="hidden" name="action" value="users/saveUser"&gt;
          &lt;input type="hidden" name="redirect" value="/account/profile"&gt;
          &lt;input type="hidden" name="userId" value="{{ currentUser.id }}"&gt;

          &lt;label for="firstName"&gt;First Name&lt;/label&gt;
          &lt;input type="text" id="firstName" name="firstName" value="{{ currentUser.firstName }}"&gt;

          &lt;label for="lastName"&gt;Last Name&lt;/label&gt;
          &lt;input type="text" id="lastName" name="lastName" value="{{ currentUser.lastName }}"&gt;

          &lt;label for="telephone"&gt;Telephone&lt;/label&gt;
          &lt;input type="text" id="telephone" name="fields[telephone]" value="{{ currentUser.telephone }}"&gt;

          &lt;h3&gt;Additional Contacts&lt;/h3&gt;

          &lt;input type="hidden" name="fields[alternativeContacts]" value=""&gt;

          {% for block in currentUser.alternativeContacts.type('contact') %}
          &lt;div class="row"&gt;
            &lt;input type="hidden" name="fields[alternativeContacts][{{ block.id }}][type]" value="contact"&gt;
            &lt;input type="hidden" name="fields[alternativeContacts][{{ block.id }}][enabled]" value="1"&gt;

            &lt;input type="text" name="fields[alternativeContacts][{{ block.id }}][fields][firstName]" value="{{ block.firstName }}"&gt;
            &lt;input type="text" name="fields[alternativeContacts][{{ block.id }}][fields][lastName]" value="{{ block.lastName }}"&gt;
            &lt;input type="text" name="fields[alternativeContacts][{{ block.id }}][fields][telephone]" value="{{ block.telephone }}"&gt;
            &lt;input type="email" name="fields[alternativeContacts][{{ block.id }}][fields][email]" value="{{ block.email }}"&gt;

            &lt;button class="btn btn-xs btn-danger" data-action="delete-contact"&gt;&lt;i class="fa fa-times"&gt;&lt;/i&gt;&lt;/button&gt;
          &lt;/div&gt;
          {% endfor %}

          &lt;div class="row"&gt;
            &lt;h6&gt;New Contact&lt;/h6&gt;

            &lt;input type="hidden" name="fields[alternativeContacts][new1][type]" value="contact"&gt;
            &lt;input type="hidden" name="fields[alternativeContacts][new1][enabled]" value="1"&gt;

            &lt;input type="text" name="fields[alternativeContacts][new1][fields][firstName]"&gt;
            &lt;input type="text" name="fields[alternativeContacts][new1][fields][lastName]"&gt;
            &lt;input type="text" name="fields[alternativeContacts][new1][fields][telephone]"&gt;
            &lt;input type="email" name="fields[alternativeContacts][new1][fields][email]"&gt;
          &lt;/div&gt;

          &lt;input type="submit" value="Save Profile"&gt;
      &lt;/form&gt;
</code></pre>

CC BY-SA 3.0
2015-01-10T10:43:59.987Z
Weirdly, if I remove the new entry field it works fine. Perhaps I'm hitting some validation issues and nothing's updating... hmmmm
GlennJ
<matrix><user-profile><frontend>
How to update Matrix field on frontend for user profile
# How to update Matrix field on frontend for user profile

(Asked by: username_0 on 2015-01-10)

I have used the following code to allow our users to update their own profile. Everything works fine apart from not being able to update existing Matrix entries.
New Matrix field entries work fine. Can anyone spot the mistake I've made?
          
          {{ getCsrfInput() }}
          
          
          

          First Name
          

          Last Name
          

          Telephone
          

          Additional Contacts

          

          {% for block in currentUser.alternativeContacts.type('contact') %}
          
            
            

            
            
            
            

            
          
          {% endfor %}

          
            New Contact

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

> **Comments:**
> **username_0**: Weirdly, if I remove the new entry field it works fine. Perhaps I'm hitting some validation issues and nothing's updating... hmmmm  

---

## 1 answers

### Answer by username_0 on 2015-01-10. Score: 2

Turns out it was a validation issue, it works fine when you make the new contact's first+last name mandatory.


---

