Why is my Super Table field returning the ID for existing blocks? I have a front-end profile form that is using a Super Table field to populate a user's phone number.

If the user has not populated the field before, everything works great. I am able to use new1 to collect the user's information.

It is when I am trying to display existing data that I am getting the error


  Impossible to access an attribute ("id") on a string variable ("92").


I am following this guide to help show existing data.

This is what my template looks like:

{% set fieldHandle = 'phoneNumber' %}
{% set field = craft.fields.getFieldByHandle(fieldHandle) %}
{% set blocktype = craft.superTable.getSuperTableBlocks(field.id)[0] %}

&lt;input type="hidden" name="fields[{{ fieldHandle }}]" value=""&gt;


&lt;label for="phoneNumber"&gt;Phone Number&lt;/label&gt;

{% if currentUser.phoneNumber.phoneNumber|length %}
    {% for block in currentUser[fieldHandle] %}
        &lt;input type="hidden" name="fields[{{ fieldHandle }}][{{ block.id }}][type]" value="{{ blocktype }}"&gt;
        &lt;input type="hidden" name="fields[{{ fieldHandle }}][{{ block.id }}][enabled]" value="1"&gt;

        &lt;input type="text" name="fields[{{ fieldHandle }}][{{ block.id }}][fields][phoneNumber]" value="{{ block.phoneNumber.phoneNumber }}"&gt;    
    {% endfor %}
{% else %}
    &lt;input type="hidden" name="fields[{{ fieldHandle }}][new1][type]" value="{{ blocktype }}"&gt;
    &lt;input type="hidden" name="fields[{{ fieldHandle }}][new1][enabled]" value="1"&gt;

    &lt;input type="text" name="fields[{{ fieldHandle }}][new1][fields][phoneNumber]"
    {%- if currentUser is defined and currentUser.phoneNumber.phoneNumber|length -%}value="{{ currentUser.phoneNumber.phoneNumber }}"{%- endif -%}&gt;
{% endif %}


While trying to debug myself, this:

{{ currentUser[fieldHandle] }} // 92


So this:

{% for block in currentUser[fieldHandle] %}


...is really saying "for block in 92". So, that is why I am getting the error, I'm not sure what the correct syntax is to resolve the error though.

My super table is set to have a max rows of 1 and static field is selected.

Thank you for any suggestions!
I think the key thing here is that its a static Super Table field, which is treated differently to a repeatable one. Instead of looping through each block, there's only one. Fortunately, you have all the required information, as this is in fact the blocktype variable.    

{% set fieldHandle = 'mySuperTableField' %}
{% set field = craft.fields.getFieldByHandle(fieldHandle) %}
{% set blocktype = craft.superTable.getSuperTableBlocks(field.id)[0] %}

&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="userId" value="{{ currentUser.id }}"&gt;

    {# Start with the top-level Super Table field #}
    &lt;input type="hidden" name="fields[{{ fieldHandle }}]" value=""&gt;

    {# Ensure any existing rows in your Super Table field are saved #}
    &lt;input type="hidden" name="fields[{{ fieldHandle }}][{{ blocktype }}][type]" value="{{ blocktype }}"&gt;
    &lt;input type="hidden" name="fields[{{ fieldHandle }}][{{ blocktype }}][enabled]" value="1"&gt;

    &lt;input type="text" name="fields[{{ fieldHandle }}][{{ blocktype }}][fields][customField1]" value="Value 1"&gt;
    &lt;input type="text" name="fields[{{ fieldHandle }}][{{ blocktype }}][fields][customField2]" value="Value 2"&gt;
    &lt;input type="text" name="fields[{{ fieldHandle }}][{{ blocktype }}][fields][customField3]" value="Value 3"&gt;

    &lt;input type="submit"&gt;
&lt;/form&gt;