Hi Djulia,
I test this code to modify certain buttons in the lists pages.
On list pages $action was being set to either blank or "list". I've set it to default to "list" for the next beta if no action is specified. This will have your code work and I think is more intuitive. A temporary alternative until you get the next build is to replace ($action == 'list') with ($action == 'list' || !$action).
Is there another approach? In fact, I would like to modify the label of the buttons. My old code ...
How about this?
addFilter('adminUI_args', function($adminUI_args, $tableName, $action) {
if ($tableName != 'words') { return $adminUI_args; }
if ($action == 'list' || !$action) {
//$adminUI_args['BUTTONS'] = array(); // erase previous buttons?
array_push($adminUI_args['BUTTONS'], [ // add to right of existing buttons?
'label' => t('My Button'),
'name' => '_action=add',
'onclick' => "window.location='?menu=" .htmlencode($tableName). "&action=add'",
'class' => 'button',
'type' => 'button',
]);
}
return $adminUI_args;
});
Outputs:
<button class="btn btn-primary button" type="button" name="_action=add" onclick="window.location='?menu=every_field_multi&action=add'">My Button</button>
Let me know if that works for you or if anything is missing.
Thanks!
Dave Edis - Senior Developer
interactivetools.com