Answers.Body: <p>Turns out this <em>was</em> a bug in Craft and we've just fixed it for the next (post build 2568) release.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-08-15T19:19:30.613Z
Answers.LastActivityDate: 2014-08-15T19:19:30.613Z
Answers.UserDisplayName: Brad Bell
Body: <p>One of the functions in a plugin that I'm working on, is the ability to create fields. It has created a Matrix field, and directly after that, I want to know the MatrixBlockType.</p>
  
  <p>I don't get any results if I use the following code:</p>
  
  <pre class="lang-php prettyprint-override"><code>$blockTypes = craft()&gt;matrix&gt;getBlockTypesByFieldId($newField-&gt;id, 'handle');
  </code></pre>
  
  <p>However, if I do the exact same thing as the above function should do, and run this code I do have results:</p>
  
  <pre class="lang-php prettyprint-override"><code>$results = craft()-&gt;db-&gt;createCommand()
  -&gt;select('id, fieldId, fieldLayoutId, name, handle, sortOrder')
  -&gt;from('matrixblocktypes')
  -&gt;where('fieldId = :fieldId', array(':fieldId' =&gt; $newField&gt;id))
  -&gt;order('sortOrder')
  -&gt;queryAll();
  </code></pre>
  
  <p>If you would debug both variables, you'll notice that the first one doesn't contain any data.</p>
  
  <p>If I would be creating the fields and in later server request I would use the first example, I do receive the data. Somehow it's not available right after creating the field.</p>
  
  <p>Can anyone help me out here by any chance? I want to use the first example, which is the correct way.</p>
  
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2014-07-06T11:46:53.023Z
Comments.Text: This looks like a bug. Try sending a mail to support@buildwithcraft.com and update this question if you can solve your problem. :)
Comments.UserDisplayName: Victor
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2014-07-13T00:48:24.970Z
Comments.Text: Why aren't there any dashes/hyphens before the greater-than signs in your first code example?
Comments.UserDisplayName: Tyler Willingham
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2014-07-13T21:40:34.993Z
Comments.Text: @Hubert Have you made any progress with this? Curious whether it ended up being a bug.
Comments.UserDisplayName: Matt Stein
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2014-07-14T06:07:30.577Z
Comments.Text: @Willingham I posted this on Google plus first. Apparently it removes the dashes.
Comments.UserDisplayName: Hubert
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2014-07-14T06:10:21.383Z
Comments.Text: @Matt No progress yet. Picked it up with Brad, so i'll update this when I know more.
Comments.UserDisplayName: Hubert
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2014-07-18T01:43:22.383Z
Comments.Text: @Hubert Replied to your ticket on the 9th and haven't heard back, just in case you didn't receive it.
Comments.UserDisplayName: Brad Bell
Tags: <plugin-development><matrix>
Title: Matrix getBlockTypesByFieldId() function doesn't work as intended?
ThreadText: # Matrix getBlockTypesByFieldId() function doesn't work as intended?
  
  (Asked by: username_0 on 2014-07-04)
  
  One of the functions in a plugin that I'm working on, is the ability to create fields. It has created a Matrix field, and directly after that, I want to know the MatrixBlockType.
  
  I don't get any results if I use the following code:
  
  ```php
  $blockTypes = craft()>matrix>getBlockTypesByFieldId($newField->id, 'handle');
  
  ```
  
  However, if I do the exact same thing as the above function should do, and run this code I do have results:
  
  ```php
  $results = craft()->db->createCommand()
  ->select('id, fieldId, fieldLayoutId, name, handle, sortOrder')
  ->from('matrixblocktypes')
  ->where('fieldId = :fieldId', array(':fieldId' => $newField>id))
  ->order('sortOrder')
  ->queryAll();
  
  ```
  
  If you would debug both variables, you'll notice that the first one doesn't contain any data.
  
  If I would be creating the fields and in later server request I would use the first example, I do receive the data. Somehow it's not available right after creating the field.
  
  Can anyone help me out here by any chance? I want to use the first example, which is the correct way.
  
  **Tags:** plugin-development, matrix
  
  > **Comments:**
  > **username_1**: This looks like a bug. Try sending a mail to support@buildwithcraft.com and update this question if you can solve your problem. :)  
  > **username_2**: Why aren't there any dashes/hyphens before the greater-than signs in your first code example?  
  > **username_3**: @username_0 Have you made any progress with this? Curious whether it ended up being a bug.  
  > **username_0**: @username_2 I posted this on Google plus first. Apparently it removes the dashes.  
  > **username_0**: @username_3 No progress yet. Picked it up with username_4, so i'll update this when I know more.  
  > **username_4**: @username_0 Replied to your ticket on the 9th and haven't heard back, just in case you didn't receive it.  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_4 on 2014-08-15. Score: 3
  
  Turns out this *was* a bug in Craft and we've just fixed it for the next (post build 2568) release.
  
  
  ---
  
  