I am looking for a D8 solution to theme the table view mode. To start, I would like to remove the main title (the "Legend" tag of the html fieldset).
Note: I know how to use hook_inline_entity_form_table_fields_alter to add/remove columns, I would like to theme what is outside the table.
After the remove of the title, I would like to remove the headers of the table ("Title", "Status", "Operations"...)
In fact, if someone have a solution, I would like to get rid of this table view mode.. My final goal is to have a very simple view mode showing only one field and the 2 action button..
Here is the solution I found to remove the header and the title: this is to preprocess fieldset and table hooks
/**
* Implements hook_preprocess_fieldset().
*/
function my_module_preprocess_fieldset(&$vars) {
//Remove the fieldset title/legend for field_myfield
//as it is a multiple value field, I check only the
//first part of the id to target field_myfield
if (strpos($vars['attributes']['id'],'dit-field-myfield')>0){
unset($vars['legend']);
unset($vars['legend_span']);
$vars['attributes']['style'][]='padding:0';
}
}
/**
* Implements hook_preprocess_table().
*/
function my_module_preprocess_table(&$vars) {
//In my use case, I need to target only table that are
//generated by ief module. I use the first part of the
//id to target it
if (strpos($vars['attributes']['id'], 'ef-entity-table')>0 ) {
//remove column headers
unset($vars['header']);
//adpat layout;
$vars['attributes']['style'][]='margin:0;border-collapse:separate';
}
}