I needed this for a custom moduel I am building.
Here are the steps…
Create file in the following format…
custom/include/generic/SugarWidgets/SugarWidget.php
In this example I will create a custom button that will eventually call a new popup page or ajax popup and guide the user through some steps before creating a record.
So I will create SugarWidgetSubPanelRSendButton.php
I am using SugarWidgetSubPanelSendInvitesButton as a template…
<?php
if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
require_once('include/generic/SugarWidgets/SugarWidgetSubPanelTopButton.php');
//class SugarWidgetSubPanelSendInvitesButton extends SugarWidgetSubPanelTopButton
class SugarWidgetSubPanelRSendButton extends SugarWidgetSubPanelTopButton
{
function display($defines, $additionalFormFields = null)
{
global $mod_strings;
//$button = '<input class="button" onclick="document.location=\'index.php?module=FP_events&action=sendinvitemails&record='.$defines['focus']->id.'\'" name="sendinvites" value="'.$mod_strings['LBL_INVITE_PDF'].'" type="button">';
$button = '<input class="button" onclick="alert(\'ACTION! :)\');" name="sendrs" value="SEND" type="button">';
return $button;
}
}
?>
Next we create a file in
custom/Extension/modules/Leads/Ext/Layoutdefs/
I am calling it customRSTopButtons.php
I enter the following…
Replace with the name of the subpanel, for example leads_documents_1
<?php
$layout_defs["Leads"]["subpanel_setup"]["<SUBPANEL NAME>"]["top_buttons"] = array(
array(
//'widget_class' => 'SubPanelTopButtonQuickCreate',
'widget_class' => 'SubPanelRSendButton',
),
array(
'widget_class' => 'SubPanelTopSelectButton',
'mode' => 'MultiSelect',
),
);
?>
Notice I am replacing the quick create button with my custom button we created earlier.
A Quick Repair and Rebuild should do it.