I have added two new fields (a Viewfield and a simple text field), and I would like to display these fields in the Inbox (/messages
) along with the existing Subject, Participants, and Last Updated data. How can I add those fields to that page ? Is there a tpl format I could use ?
1 Answer
/**
* Implements hook_form_alter().
*/
function modulename_form_alter(&$form, &$form_state, $form_id) {
if ($form_id == 'privatemsg_list') {
$form['updated']['list']['#header']['bar_column_field']['data'] = 'Bar Column';
$form['updated']['list']['#header']['bar_column_field']['field'] = 'bar_column_field';
$form['updated']['list']['#header']['bar_column_field']['class'][] = 'privatemsg-header-bar-column';
$form['updated']['list']['#pre_render'][] = '_pre_render_bar_column';
}
/**
* Custom #pre_render function.
*/
function _pre_render_bar_column($tableselect) {
$i = 0;
foreach ($tableselect['#options'] as $id => $options) {
$data = 'Bar data in the table ' . $i++ . '';
$tableselect['#options'][$id]['bar_column_field'] = array('data' => $data, 'class' => array('privatemsg-list-bar'));
}
return $tableselect;
}
You can change the $data
variable with any field's value, after performing a query or something, and placing your actual data to the new column.
A field could be attached to messaging (admin/config/messaging/privatemsg/fields
) or to any other available entity.