How can multiple fieldtype instances without a content column be attached to the same entry type and still be uniquely identifiable? We have a custom fieldtype that can be attached to an entry type multiple times and everything works just fine. This fieldtype has multiple input fields (shortUrl, longUrl) and they have been properly namespaced to make them unique (via the fieldtype handle) and when the data is saved, it gets saved to a table that defines the necessary columns (id, elementId, shortUrl, longUrl) since the defineContetAttribute() method has been set to false.

As previously mentioned, this fieldtype has been properly namespaced and is taking advantage of the Craft JS buffer to avoid naming conflicts.

The issue comes up when we try to retrieve the data from our custom table via preValue($value) because $value will be null and all the other values we have access to in this context  ($field-&gt;model-&gt;id, $field-&gt;model-&gt;handle, $field-&gt;element-&gt;id) are not unique enough to fetch a record.

I've tried a couple of workarounds but have not found a clean way to do this yet.

The prepValue() method provides the entry id ($field-&gt;element-&gt;id) which we can use to fetch the content (record) for each field since we have a relationship set but beyond that, I haven't found any other way to identify each record individually so that I can attach it to the right field instance within the input html.

There might be something simple that I'm missing and thought I would ask: )
Since you're saving your data in a separate table, you basically need two fields within your custom table to help you identify which field &amp; element originally saved the content:


The element id (which you're already storing)
The field id (missing from your current setup)


You could even create an index on your custom table that would be a combo of those two fields.

In theory, you should be able to retrieve your data with a combination of the $field-&gt;model-&gt;id and $field-&gt;element-&gt;id.

When saving:

$attr['elementId'] = $field-&gt;element-&gt;id;
$attr['fieldId']   = $field-&gt;model-&gt;id;

$fieldRecord-&gt;setAttributes($attr);


When retrieving:

$fieldRecord = MyPlugin_FieldRecord::model()-&gt;findByAttributes(array(
    'elementId' =&gt; $field-&gt;element-&gt;id,
    'fieldId'   =&gt; $field-&gt;model-&gt;id,
));