<p>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 <code>blocktype</code> variable.    </p>

<pre><code>{% 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;
</code></pre>

CC BY-SA 3.0
2017-06-13T08:00:09.100Z
2017-06-13T08:00:09.100Z
crawf
<p>I have a front-end profile form that is using a Super Table field to populate a user's phone number.</p>

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

<p>It is when I am trying to display existing data that I am getting the error</p>

<blockquote>
  <p>Impossible to access an attribute ("id") on a string variable ("92").</p>
</blockquote>

<p>I am following <a href="https://github.com/engram-design/SuperTable/wiki/Updating-a-Super-Table-field-from-a-front-end-form" rel="nofollow noreferrer">this guide</a> to help show existing data.</p>

<p>This is what my template looks like:</p>

<pre><code>{% 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 %}
</code></pre>

<p>While trying to debug myself, this:</p>

<pre><code>{{ currentUser[fieldHandle] }} // 92
</code></pre>

<p>So this:</p>

<pre><code>{% for block in currentUser[fieldHandle] %}
</code></pre>

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

<p><strong>My super table is set to have a max rows of 1 and static field is selected.</strong></p>

<p>Thank you for any suggestions!</p>

<templating><plugin-supertable>
Why is my Super Table field returning the ID for existing blocks?
# Why is my Super Table field returning the ID for existing blocks?

(Asked by: username_0 on 2017-06-12)

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] %}




Phone Number

{% if currentUser.phoneNumber.phoneNumber|length %}
    {% for block in currentUser[fieldHandle] %}
        
        

            
    {% endfor %}
{% else %}
    
    

    
{% 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!

**Tags:** templating, plugin-supertable

---

## 1 answers

### Answer by username_1 on 2017-06-13. Score: 3 | Accepted answer

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] %}


    {{ getCsrfInput() }}
    
    

    {# Start with the top-level Super Table field #}
    

    {# Ensure any existing rows in your Super Table field are saved #}


---

