Answers.Body: 
  
  <p>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 <code>$matrixBlock-&gt;fieldId</code>.</p>
  
  <p>Once you know the Matrix field’s ID, you can get all its block types like this:</p>
  
  <pre class="lang-php prettyprint-override"><code>$blockTypes = craft()-&gt;matrix-&gt;getBlockTypesByFieldId($matrixFieldId);
  </code></pre>
  
  <p>That will give you an array of MatrixBlockTypeModel objects. From there you can loop through each of those and get their fields like this:</p>
  
  <pre class="lang-php prettyprint-override"><code>foreach ($blockTypes as $blockType)
  {
      $fields = $blockType-&gt;getFields();
  
      // ...
  }
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-07-07T23:49:08.587Z
Answers.Text: Brilliant, that totally did the trick! Thanks a ton Brandon, I appreciate the quick response. :)
Answers.UserDisplayName: Lindsey D
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-07-07T23:52:08.413Z
Answers.Text: What is the relationship between the MatrixBlockModel and the MatrixBlockTypeModel?  I'm missing something about how the two relate to one another...  Maybe another part of this question is what is the relationship of both of these to the FieldModel?
Answers.UserDisplayName: Ben Parizek
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-07-07T23:57:30.473Z
Answers.Text: From $matrixBlockModel, you can do $matrixBlockModel->getType(), to get a MatrixBlockTypeModel.
Answers.UserDisplayName: Brad Bell
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-07-08T00:01:04.733Z
Answers.Text: @BenParizek MatrixBlockModel represents an individual Matrix block, created from within a Matrix field on an entry, etc., whereas MatrixBlockTypeModel represents a block **type**, as defined in the Matrix field’s settings (its name, its handle, and which sub-fields it has).
Answers.UserDisplayName: Brandon Kelly
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-07-07T23:30:27.957Z
Answers.LastActivityDate: 2014-07-07T23:30:27.957Z
Answers.UserDisplayName: Brandon Kelly
Answers.Body: <p>With a MatrixBlockModel you can get the MatrixBlockTypeModel like so:</p>
  
  <pre><code>$matrixBlockTypeModel = $matrixBlockModel-&gt;getType();
  </code></pre>
  
  <p>You can get the FieldModel of all the fields associated with that type with the <code>getFields()</code> method on the MatrixBlockTypeModel:</p>
  
  <pre><code>$fields = $matrixBlockTypeModel-&gt;getFields();
  </code></pre>
  
  <p>If you needed the FieldLayoutFieldModel you could access them like so</p>
  
  <pre><code>$fields = $matrixBlockTypeModel-&gt;getFieldLayout()-&gt;getFields();
  </code></pre>
  
  <p><em>NOTE: This answer misses the question as the original question requested all fields from the parent Matrix field, which would require looping through all of the MatrixBlockTypeModels as Brandon describes above.  I've tried to update this answer to at least provide some related information instead of just being wrong or a duplicate of the one above!</em></p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-07-07T23:49:36.277Z
Answers.Text: Didn't quite do it for me, but I appreciate the quick response. Thanks Ben!
Answers.UserDisplayName: Lindsey D
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-07-07T23:50:58.740Z
Answers.Text: Yeah, I was off base referencing the MatrixBlockModel instead of the MatrixBlockTypeModel.  I'll update this with how to connect the dots with what I learn when I have a chance!
Answers.UserDisplayName: Ben Parizek
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-07-07T23:52:43.400Z
Answers.Text: Fair enough, though the `MatrixBlockModel` was my starting point. Brandon's answer totally worked... but if you've got another technique, I'm definitely curious. :)
Answers.UserDisplayName: Lindsey D
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-07-07T23:57:07.460Z
Answers.Text: Really, I'm just trying to make my answer not crappy and wrong entirely =)
Answers.UserDisplayName: Ben Parizek
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-07-07T23:57:46.247Z
Answers.Text: Lol, sounds good to me!
Answers.UserDisplayName: Lindsey D
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-07-08T05:28:05.447Z
Answers.Text: Ben I can jump in and not even pass the breath test...
Answers.UserDisplayName: cmcjane
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-07-08T05:30:41.850Z
Answers.Text: *though I do have to say after listening to your training videos again this week, I was able to infer the difference between the  the MatrixBlockModel and the MatrixBlockTypeModel on the first pass, from your head to mine.  Ain't life grand?
Answers.UserDisplayName: cmcjane
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-07-07T23:29:12.960Z
Answers.LastActivityDate: 2014-07-08T00:20:57.050Z
Answers.LastEditDate: 2014-07-08T00:20:57.050Z
Answers.UserDisplayName: Ben Parizek
Body: <p>If I want to get a list of all fields that I've defined on the site, I can do this:</p>
  
  <pre><code>craft()-&gt;fields-&gt;getAllFields()
  </code></pre>
  
  <p>But how do I get a list of <strong>all sub-fields defined within a Matrix field?</strong></p>
  
  <p>I have access to the <code>MatrixBlockModel</code>, if that helps.</p>
  
Tags: <plugin-development><matrix>
Title: How can I list all sub-field handles of a Matrix parent field?
ThreadText: # How can I list all sub-field handles of a Matrix parent field?
  
  (Asked by: username_0 on 2014-07-07)
  
  If I want to get a list of all fields that I've defined on the site, I can do this:
  
  ```
  craft()->fields->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.
  
  **Tags:** plugin-development, matrix
  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_1 on 2014-07-07. Score: 5 | Accepted answer
  
  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->fieldId`.
  
  Once you know the Matrix field’s ID, you can get all its block types like this:
  
  ```php
  $blockTypes = craft()->matrix->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:
  
  ```php
  foreach ($blockTypes as $blockType)
  {
      $fields = $blockType->getFields();
  
      // ...
  }
  
  ```
  
  > **Comments:**
  > **username_0**: Brilliant, that totally did the trick! Thanks a ton username_1, I appreciate the quick response. :)  
  > **username_2**: What is the relationship between the MatrixBlockModel and the MatrixBlockTypeModel?  I'm missing something about how the two relate to one another...  Maybe another part of this question is what is the relationship of both of these to the FieldModel?  
  > **username_3**: From $matrixBlockModel, you can do $matrixBlockModel->getType(), to get a MatrixBlockTypeModel.  
  > **username_1**: @username_2 MatrixBlockModel represents an individual Matrix block, created from within a Matrix field on an entry, etc., whereas MatrixBlockTypeModel represents a block **type**, as defined in the Matrix field’s settings (its name, its handle, and which sub-fields it has).  
  
  ---
  
  ### Answer by username_2 on 2014-07-07. Score: 2
  
  With a MatrixBlockModel you can get the MatrixBlockTypeModel like so:
  
  ```
  $matrixBlockTypeModel = $matrixBlockModel->getType();
  
  ```
  
  You can get the FieldModel of all the fields associated with that type with the `getFields()` method on the MatrixBlockTypeModel:
  
  ```
  $fields = $matrixBlockTypeModel->getFields();
  
  ```
  
  If you needed the FieldLayoutFieldModel you could access them like so
  
  ```
  $fields = $matrixBlockTypeModel->getFieldLayout()->getFields();
  
  ```
  
  *NOTE: This answer misses the question as the original question requested all fields from the parent Matrix field, which would require looping through all of the MatrixBlockTypeModels as username_1 describes above. I've tried to update this answer to at least provide some related information instead of just being wrong or a duplicate of the one above!*
  
  > **Comments:**
  > **username_0**: Didn't quite do it for me, but I appreciate the quick response. Thanks Ben!  
  > **username_2**: Yeah, I was off base referencing the MatrixBlockModel instead of the MatrixBlockTypeModel.  I'll update this with how to connect the dots with what I learn when I have a chance!  
  > **username_0**: Fair enough, though the `MatrixBlockModel` was my starting point. username_1's answer totally worked... but if you've got another technique, I'm definitely curious. :)  
  > **username_2**: Really, I'm just trying to make my answer not crappy and wrong entirely =)  
  > **username_0**: Lol, sounds good to me!  
  > **username_4**: Ben I can jump in and not even pass the breath test...  
  > **username_4**: *though I do have to say after listening to your training videos again this week, I was able to infer the difference between the  the MatrixBlockModel and the MatrixBlockTypeModel on the first pass, from your head to mine.  Ain't life grand?  
  
  ---
  
  