I got this issue reported in Entityforms #1975266: Features export should autodetect fields
I tested it and basically fields were not be exported with an Entityform Type(which uses 'bundle of') when using features 2.x branch. I also confirmed this is happening with Profile2 types. Both use the EntityDefaultFeaturesController.
I tracked down the problem to EntityDefaultFeaturesController->export().
// If this is a bundle of a fieldable entity, add its fields to the pipe.
if (!empty($this->info['bundle of'])) {
$fields = field_info_instances($this->info['bundle of'], $entity->{$this->bundleKey});
foreach ($fields as $name => $field) {
$pipe['field'][] = "{$field['entity_type']}-{$field['bundle']}-{$field['field_name']}";
}
}This works fine for Features 1.x but not for 2.x.
I found that Features own implementation to export content types also exports the field instances not just the bases.
From node_features_export().
$fields = field_info_instances('node', $type);
foreach ($fields as $name => $field) {
$pipe['field'][] = "node-{$field['bundle']}-{$field['field_name']}";
$pipe['field_instance'][] = "node-{$field['bundle']}-{$field['field_name']}";
}Added the extra line to extra line to also export the field instances and this then exports the fields with Features 2.x
// If this is a bundle of a fieldable entity, add its fields to the pipe.
if (!empty($this->info['bundle of'])) {
$fields = field_info_instances($this->info['bundle of'], $entity->{$this->bundleKey});
foreach ($fields as $name => $field) {
$pipe['field'][] = "{$field['entity_type']}-{$field['bundle']}-{$field['field_name']}";
$pipe['field_instance'][] = "{$field['entity_type']}-{$field['bundle']}-{$field['field_name']}";
}
}Patch attached.
| Comment | File | Size | Author |
|---|---|---|---|
| entity-export_field_instances.patch | 587 bytes | tedbow |
Comments
Comment #1
ciss commentedUsing features-7.x-2.0-rc1 this patch works great.
It also still applies against entity-7.x-1.1+2-dev (2013-May-20).
Comment #2
coline commentedThank you tedbow for sharing your patch.
It worked perfectly with me :
- Entity API : 7.x-1.6
- EntityForm : 7.x-2.0-rc1
- Features : 7.x-2.0-rc1
Comment #4
ciss commentedComment #6
fagoThanks, committed!