<p>That's more complicated, because fields in a Matrix are scoped to the Matrix field, which is why you can't just go:</p>

<p><code>{% set field = craft.fields.getFieldByHandle('superTableFieldInMatrix') %}</code></p>

<p>You'll need to loop through the Matrix's fields to find the Super Table field, then carry on as normal.</p>

<pre><code>{% set matrixField = craft.fields.getFieldByHandle('myMatrixField') %}

{% for field in matrixField.getBlockTypeFields() %}
    {% if field.handle == 'mySuperTableField' %}
        {% set blocktype = craft.superTable.getSuperTableBlocks(field.id)[0] %}
</code></pre>

CC BY-SA 4.0
2019-09-10T14:01:11.740Z
2019-09-10T14:01:11.740Z
crawf
<p>I'm making a front-end entry form with a Super Table field that is inside a Matrix field. Super Table docs at <a href="https://verbb.io/craft-plugins/super-table/docs/template-guides/front-end-form" rel="nofollow noreferrer">https://verbb.io/craft-plugins/super-table/docs/template-guides/front-end-form</a> have an example with the following code to figure out a block type of Super Table field:</p>

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

<p>If in my case I have a Matrix field with handle myMatrixFeild that contains mySuperTableField, how do I find out the block type of mySuperTableField?</p>

<craft3><matrix><plugin-supertable>
How to find the block type of Super Table field that is inside a Matrix field
# How to find the block type of Super Table field that is inside a Matrix field

(Asked by: username_0 on 2019-07-01)

I'm making a front-end entry form with a Super Table field that is inside a Matrix field. Super Table docs at https://verbb.io/craft-plugins/super-table/docs/template-guides/front-end-form have an example with the following code to figure out a block type of Super Table field:
{% set fieldHandle = 'mySuperTableField' %}
{% set field = craft.fields.getFieldByHandle(fieldHandle) %}
{% set blocktype = craft.superTable.getSuperTableBlocks(field.id)[0] %}

If in my case I have a Matrix field with handle myMatrixFeild that contains mySuperTableField, how do I find out the block type of mySuperTableField?

**Tags:** craft3, matrix, plugin-supertable


---

## 1 answers

### Answer by username_1 on 2019-09-10. Score: 3

That's more complicated, because fields in a Matrix are scoped to the Matrix field, which is why you can't just go:
{% set field = craft.fields.getFieldByHandle('superTableFieldInMatrix') %}
You'll need to loop through the Matrix's fields to find the Super Table field, then carry on as normal.
{% set matrixField = craft.fields.getFieldByHandle('myMatrixField') %}

{% for field in matrixField.getBlockTypeFields() %}
    {% if field.handle == 'mySuperTableField' %}
        {% set blocktype = craft.superTable.getSuperTableBlocks(field.id)[0] %}


---

