How can I list all sub-field handles of a Matrix parent field? If I want to get a list of all fields that I've defined on the site, I can do this:

craft()-&gt;fields-&gt;getAllFields()


But how do I get a list of all sub-fields defined within a Matrix field?

I have access to the MatrixBlockModel, if that helps.
You’ll need to start by figuring out the Matrix field’s ID. If you already have a MatrixBlockModel object as you say, you can get that via $matrixBlock-&gt;fieldId.

Once you know the Matrix field’s ID, you can get all its block types like this:

$blockTypes = craft()-&gt;matrix-&gt;getBlockTypesByFieldId($matrixFieldId);


That will give you an array of MatrixBlockTypeModel objects. From there you can loop through each of those and get their fields like this:

foreach ($blockTypes as $blockType)
{
    $fields = $blockType-&gt;getFields();

    // ...
}