I have 2 content type. I want content type 2 to contain a custom field that holds the following information in that field:
- Text field 1
- Text field 2
- Entity reference to Content type 1
I declared my hook_field_info() along with the widget_info, formatter info and hook_field_schema.
And used the entityreference_autocomplete contrib (https://www.drupal.org/project/entityreference_autocomplete) for the entityreference field within my widget.
All works well except for the fact that Drupal throws a PDO exception when saving the node that has the custom field.
It tells me that the insert value list does not match column list: 1136 Column count doesn't match value count.
After some debugging, I discovered that the entityreference_autocomplete field is trying to save all params (entity type, bundle, entity_id, ...) to my table. Where I just want then entity_id that is referenced to be saved (just like entity_reference works by default).
Any ideas on how to fix this?
I wanted to take this approach to avoid using field_collections...
It is also important to note that i will need to build a view based on this custom field's entity reference.
Many thanks in advance
Autocomplete implementation in field widget
$element['service_category'] = array( '#type' => 'entityreference', '#title' => t('Service Category'), '#era_entity_type' => 'node', '#era_bundles' => array('service_category'), '#era_cardinality' => 1, );