Hi,
I have tried to use your module with addressfield and geofield as part of a field collection.
Both 7.x-1.0-beta5 version and 7.x-1.x-dev version don't work.
7.x-1.x-dev version reported an error at row 631 of addressfield_autocomplete.module in the function _addressfield_autocomplete_widget_get_field_value.
"undefined property $entity->type".
I have found that the offending row is
$bundle_name = $entity_type == 'taxonomy_term' ? $entity->vocabulary_machine_name : $entity->type;
With the field collection module $entity_type is always "field_collection_item" while $entity->type is not defined, but you can substitute it with $entity->field_name.
So I have solved the problem changing row 631 from
$bundle_name = $entity_type == 'taxonomy_term' ? $entity->vocabulary_machine_name : $entity->type;
to
if(!property_exists($entity, 'type') && isset($entity->field_name) )
{
$bundle_name = $entity->field_name;
}
else
{
$bundle_name = $entity_type == 'taxonomy_term' ? $entity->vocabulary_machine_name : $entity->type;
}
....
follows
$field_name = $instance['widget']['settings']['addressfield_autocomplete_field'];
$field_instance = field_info_instance($entity_type, $field_name, $bundle_name);
I have uploaded two files: one for the beta5 version and the other for the dev version; both seem to be working.
| Comment | File | Size | Author |
|---|---|---|---|
| #5 | interdiff-2515404-6-7.txt | 1.06 KB | tibezh |
| #5 | addressfield_autocomplete-support_field_collections_and_other_entitites-2515404-5-7.patch | 1.11 KB | tibezh |
Comments
Comment #1
giaza commentedComment #2
giaza commentedComment #3
mvlabat commentedThanks for your work. The fix seems to be working.
Here is the patch in right format.
Comment #4
tibezh commentedI have some problem but with user entity. My patch fix field collections and user entity (maybe other entities) as well.
Comment #5
tibezh commentedHere is a new patch for a module, I have written universal code for fetch bundle of any entity type use Entity API module.
Comment #6
thedut commented#5 is a create patch. I confirm it works with Field Collection and User addressbook.
Comment #8
adammitchell commentedHi all,
Sorry for the delay in responding. I have committed a fix to the dev branch which should hopefully mean that it is fixed universally. It also does not require anymore dependencies.
Would be great if you guys could find the time to review it.
Thanks,
Adam
Comment #9
thedut commentedHello Adam,
I tested your fix with a taxonomy term entity :
I didn't try this fix with field collection entity.