我创建了一个自定义列来显示上次用户更改的时间,但我需要在OPERATIONS列之前插入此字段。下面是我的代码,它在最后附加我的自定义字段。
function meme_user_update_form_user_admin_account_alter(&$form, &$form_state, $form_id) {
$changed_column = array('changed' => array(
'data' => 'LAST CHANGED',
'field' => 'u.changed'
));
$form['accounts']['#header'] = $form['accounts']['#header'] + $changed_column;
foreach ($form['accounts']['#options'] as $key => $row) {
$user_object = user_load($key);
$user_language = ($user_object->language) ? $user_object->language : LANGUAGE_NONE;
$form['accounts']['#options'][$key]['changed'] = $user_object->field_user_changed[$user_language][0]['value'];
}
}
答案 0 :(得分:0)
找到答案,我认为这可能有助于某人。
function meme_user_update_form_user_admin_account_alter(&$form, &$form_state, $form_id) {
$changed_column = array(
'data' => 'LAST CHANGED',
'field' => 'u.changed'
);
$operation_column = array_pop($form['accounts']['#header']);
$form['accounts']['#header']['changed'] = $changed_column;
$form['accounts']['#header']['operations'] = $operation_column;
foreach ($form['accounts']['#options'] as $key => $row) {
$user_object = user_load($key);
$user_language = ($user_object->language) ? $user_object->language : LANGUAGE_NONE;
$operation_column = array_pop($form['accounts']['#options'][$key]);
$form['accounts']['#options'][$key]['changed'] = $user_object->field_user_changed[$user_language][0]['value'];
$form['accounts']['#options'][$key]['operations']['data'] = $operation_column;
}
}