I have custom entity with just a base table and it is referenced with the node with its field field_a. Now I want to create the relationship between these two entities (node and my custom entity). I can get the result working but I am not getting the node fields listed in the views field section.
// Base table for custom entity is "clinical_trial_research_sites"
function clinical_trial_views_data_alter(&$data) {
$data['clinical_trial_research_sites']['node'] = array(
'title' => t('Clinical Trial'),
'help' => t('Field Reference Appear in Location Content type.'),
// Information of the referenced table!!
'relationship' => array(
'handler' => 'views_handler_relationship',
'label' => t('Location'),
'base' => 'field_data_field_site_comp_code', // node field table name
'base field' => 'field_site_comp_code_value', // field column name of node field
'relationship field' => 'site_comp_code', // This is referencing field in my custom entity
),
);
}
I can get the sql working , inner join working but views is not listing all the fields of the node as I want to display the some of the fields from the nodes too!!. I think I am missing some information to tell the views that relationship is not only field table but with the node as a whole!!
I fixed it by copying some of the code from the entityreference. I have to use a different views handler for this relationship and add other attributes to that relationship