I've been trying to add AJAX buttons for a while. I am able to do it on forms, like this:
function hook_form_alter(&$form, &$form_state, $form_id) {
$form['suspend'] = array(
'#type' => 'button',
'#name' => 'foo',
'#value' => t('bar'),
'#ajax' => array('callback' => '_foo_bar'),
);
return $form;
}
working fine. However I cannot get it to work on user profiles or non-forms, like this:
function hook_user_view_alter(&$build) {
$build['suspend'] = array(
'#type' => 'button',
'#name' => 'foo',
'#value' => t('bar'),
'#ajax' => array('callback' => '_foo_bar'),
);
return $build;
}
Are there simple ways of doing this? I use blocks & views on this site and would rather not have to install Panels if possible (:
Thanks!