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

function &_get_form($defines, $additionalFormFields = null){
$button = parent::_get_form($defines, $additionalFormFields);
$button .= '<input type="hidden" name="description" value="What the Button Says" />' . "\n";
return $button;
}

The display function itself can be (but doesn’t necessarily need to be) overridden or extended.

If you’re having issues with the labeling (I did), you can also put a few lines to define the labels in the same method:

function &_get_form($defines, $additionalFormFields = null){
$button = parent::_get_form($defines, $additionalFormFields);
$button .= '<input type="hidden" name="description" value="What the Button Says" />' . "\n";
$this->title = $defines['subpanel_definition']->mod_strings['LBL_NEW_BUTTON_TITLE'];
$this->access_key = $defines['subpanel_definition']->mod_strings['LBL_NEW_BUTTON_KEY'];
$this->form_value = $defines['subpanel_definition']->mod_strings['LNK_NEW_CALL'];
return $button;
}
This entry was posted in SugarCRM. Bookmark the permalink. Post a comment or leave a trackback: Trackback URL.

Post a Comment

Your email is never published nor shared. Required fields are marked *

*
*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Sage President\

Profiling Solutions, Inc
174 Carroll Street
Atlanta, GA 30312
Sales: 1 (866) 515-9959
Office Phone: (404) 525-8003
Office Fax: (404) 525-8005
info@profilingsolutions.com