Blog Categories

SugarCRM Developers on Twitter

Creating Your Own Subpanel Top Button

Frequent SugarCRM users know the value in the placement of buttons, and adding buttons to the top of a subpanel can be a signficant time-saver. With Sugar’s extensibility, you can easily-enough create a new button from scratch, or override the functionality of an existing Create or Select button.

Go ahead and create custom/include/generic/SugarWidgets/SugarWidget<yada-yada-yada>.php. Make sure you prefix the name with SugarWidget, even if you’re extending a field, e.g. SugarWidgetCustomSubPanelTopScheduleCallButton. The names are long and case-sensitive on *nix systems, so be careful.

Depending on what sort of button you want, you’ll almost certainly start by extending an existing button class. If you’re overriding the Log Call button for Activities subpanel, you’ll use start with class SugarWidgetCustomSubPanelTopScheduleCallButton extends SugarWidgetSubPanelTopScheduleCallButton. However, if you have a somewhat more generic Create button, you might opt for class SugarWidgetCustomSubPanelTopButtonQuickCreate extends SugarWidgetSubPanelTopButtonQuickCreate.

And what to do with it? Look to define the method _get_form(). If you’re overriding things completely, just start gathering your content into a single var ($button is conventionally used) and return the variable at the end of your function. If you’re extending another button, you’ll probably first want to call the parent method first, like