SugarCRM SupportProduct GuidesSugar DeveloperSugar Developer Guide 11.1CookbookModifying Subpanel Buttons
This release is only available for SugarCloud customers.

Modifying Subpanel Buttons

Overview

Several buttons exist on each subpanel by default such as "Create" (+ Plus symbol) and "Link Existing Record". These buttons are controlled by the panel-top view for each module. To make changes to the buttons included in a subpanel layout, you will need to create an override for the panel-top view in ./custom/Extension/modules/<module>/Ext/clients/base/views/panel-top/ and update the corresponding buttons property to include or exclude a button.

If you need to make changes to a specific relationships subpanel, then you will need to modify the subpanels layout definition for the relationship to point to a custom panel-top view that you define.

Steps to Complete

Editing Subpanel Buttons

In this example, we will remove the "Create" button from the Contacts subpanel for all modules. This code snippet uses the same button definition that the create button uses. It has been changed to trigger the "Link Existing Record" action by setting the button type to link-action. The blank array after the initial button is just to assure that the drop-down button displays next to it as disabled for placement purposes.

  1. Create the file custom/Extension/modules/Contacts/Ext/clients/base/views/panel-top/panel-top.php as follows:
    <?php
    
    $viewdefs['Contacts']['base']['view']['panel-top']['buttons'] = array(
        array(
            'type' => 'actiondropdown',
            'name' => 'panel_dropdown',
            'css_class' => 'pull-right',
            'buttons' => array(
                array(
                    'type' => 'link-action',
                    'icon' => 'fa-link',
                    'name' => 'select_button',
                    'label' => ' ',
                    'tooltip' => 'LBL_ASSOC_RELATED_RECORD',
                ),
                array(
                ),
            ),
        ),
    );
  2. Navigate to Admin > Repair and click "Quick Repair and Rebuild".

The subpanel will appear as shown below for all Contacts subpanels.

Action-Button-Changes

Using a Custom Panel-Top View for a Specific Relationship

In this example, we will only remove the "Create" action from a specific relationships subpanel. Specifically, the example will look at Contacts subpanel on the Accounts module and implement the above changes explicitly for that relationship.

  1. Create the custom panel-top view in ./custom/modules/Contacts/clients/base/views/panel-top-for-accounts/panel-top-for-accounts.php as follows:
    <?php
    
    $viewdefs['Contacts']['base']['view']['panel-top-for-accounts'] = array(
        'type' => 'panel-top',
        'template' => 'panel-top',
        'buttons' => array(
            array(
                'type' => 'actiondropdown',
                'name' => 'panel_dropdown',
                'css_class' => 'pull-right',
                'buttons' => array(
                    array(
                        'type' => 'link-action',
                        'icon' => 'fa-link',
                        'name' => 'select_button',
                        'label' => ' ',
                        'tooltip' => 'LBL_ASSOC_RELATED_RECORD',
                    ),
                    array(
                    ),
                ),
            ),
        ),
    );
  2. Create the subpanel panel-top override definition for Accounts in ./custom/modules/Accounts/clients/base/layouts/subpanels/subpanels.php as follows: 
    <?php
    
    require 'modules/Accounts/clients/base/layouts/subpanels/subpanels.php';
    
    foreach($viewdefs['Accounts']['base']['layout']['subpanels']['components'] as $key => $component){
        if ($component['context']['link'] == 'contacts'){
            $viewdefs['Accounts']['base']['layout']['subpanels']['components'][$key]['override_paneltop_view']  = 'panel-top-for-accounts';
            break;
        }
    }
  3. Navigate to Admin > Repair and click "Quick Repair and Rebuild".

Your changes will now be reflected in the system.

Last modified: 2021-08-03 13:28:33