Return element criteria model from attribute of a model In one of my Plugin's CP templates I am using a element select field to grab elements from a custom element type.  This field saves an array of element ids to a specific record's attribute called "location".  How do you return an element criteria model instead of the array of ids when the model attribute is called via twig?

// Model
protected function defineAttributes()
{
    return array_merge(parent::defineAttributes(), array(
        'location'          =&gt; Attributetype::Mixed,
        'specificLocation'  =&gt; AttributeType::String,
        'registration'      =&gt; AttributeType::Mixed,
    ));
}

// Front end template
{{ craft.pluginname.variable.location }}
If I'm following you correctly, seems like you could override your Model's getAttribute method to do something like this completely untested code:

public function getAttribute($name, $flattenValue = false)
{
    if ($name == 'location' &amp;&amp; $flattenValue != false)
    {
        $criteria = craft()-&gt;elements-&gt;getCriteria('MyPlugin_MyElementType');
        $criteria-&gt;location = parent::getAttribute($name, $flattenValue);
        return $criteria;
    }

    return parent::getAttribute($name, $flattenValue);
}


If I'm not following you correctly, then that was pointless.