Module Development - Get ID of a field within a Matrix field I have a matrix field that has a Supertable matrix within it.

I need to programatically get the ID of the field that is nested in the Matrix.

I have the code below:

$matrixField = Craft::$app-&gt;getFields()-&gt;getFieldByHandle('myMatrixFieldHandle');


Which gets me my Matrix field element, but I can't figure out how to get the fields that are within that Matrix field and thus the ID of the field within the Matrix field.

Any help appreciated!
You'll need to loop through the fields in the blocktype definition for your Matrix field. For simplicities sake, I've supplied a loop, which you can cut-down if you have a specific block type in mind you just want to fetch for:

$matrixField = Craft::$app-&gt;getFields()-&gt;getFieldByHandle('myMatrixFieldHandle');

foreach ($matrixField-&gt;getBlockTypes() as $key =&gt; $blockType) {
    Craft::dump($blockType-&gt;name);

    foreach ($blockType-&gt;getFields() as $key =&gt; $field) {
        Craft::dump($field-&gt;name);
    }
}