How would I setup my plugin to use a unique fieldlayout that is unique to the top level of the plugin? For example: Users. You can only have one fieldlayout per ElementType user which you customize in the settings section.

I've got as far as abstracting out the fieldlayout to it's own view, but when I go to set the field layout in the controller I'm borrowing the following code:

// Set the field layout
$fieldLayout = craft()-&gt;fields-&gt;assembleLayoutFromPost(false);
$fieldLayout-&gt;type = ElementType::MyElementType;


To which I get the following (pretty much expected) error:

 Fatal error: Undefined class constant 'MyElementType' in /controllers/MyElementTypeController.php on line 115


I've looked at how the plugin example "Events" is handling this and Brandon seems to be setting the fieldlayout->type to Assets:

$fieldLayout = craft()-&gt;fields-&gt;assembleLayoutFromPost();
$fieldLayout-&gt;type = ElementType::Asset;
$calendar-&gt;setFieldLayout($fieldLayout);


Is this how we're supposed to be setting these up? i.e., borrowing from other elementtypes?
You're bumping into this error because of a minor misunderstanding of how Pixel &amp; Tonic are referencing their Element Types. The problem you have is with this line of code:

$fieldLayout-&gt;type = ElementType::MyElementType;


When P&amp;T use that syntax, it's because they've already pre-defined all of their element types as enums. Open up the /app folder and take a look at this file to see what they've done:


  /craft/app/enums/ElementType.php


This allows them to use a syntax like ElementType::Asset.

You don't have that option (unless you create your own enum). What you would do instead, simply use a normal string to specify your element type:

$fieldLayout-&gt;type = 'MyPlugin_MyElementType';


This is the same string that you wrote when you defined the Model for your Element Type. It should be one of the first lines of code within your Model:

protected $elementType = 'MyPlugin_MyElementType';


Setting up enums is a different topic, but just go ahead and use the string and it should resolve that error for you!