Results 1 to 3 of 3

Thread: custom field in subpanel

  1. #1
    eitrix's Avatar
    eitrix is offline Sugar Community Member
    Join Date
    Aug 2010

    Red face custom field in subpanel

    Today i want to share with you, how you can add custom field into subpanel. We will show on example of Contracts subpanel that is showing in Accounts module/detailview.
    First thing that needs to be done is define a new field in subpanel definition and make that field point to a class. We are edititing the following file custom/modules/Contracts/metadata/subpanels/ForAccounts.php and adding additional field fot showing with following code:
    'vname' => 'LBL_EONTEK_NEW_FIELD',
    'widget_class' => 'SubPanelEontekNewField', //remember this class name
    'width' => '10%',
    'custom_link_only' => true,
    'displayHeaderCell' => false,

    After we have added that part of code we need to create coresponding SugarWidgetSubPanel class in the following path
    with code like this:
    if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
    class SugarWidgetSubPanelEonteknewField extends SugarWidgetField //look at name of class
    function displayHeaderCell(&$layout_def){
    if(!empty($layout_def['displayHeaderCell']) && $layout_def['displayHeaderCell'] == false) {
    return '&nbsp;';
    else {
    return parent::displayHeaderCell($layout_def);
    function displayList(&$layout_def)
    global $focus;
    $key = strtoupper($layout_def['varname']);
    $key = $this->_get_column_alias($layout_def);
    $key = strtoupper($key);
    // Current ProductTemplate record (in current subpanel row)
    $module = $layout_def['module'];
    $record = $layout_def['fields']['ID']; //id contract
    $contractName = $layout_def['fields']['NAME']; //name contract


    // Current ProductTemplate record
    $parent_id=$_REQUEST['record']; //id account-a
    //Here you define your logic, my quary to the database and the return from this function will be displayed in subpanel
    //So for example you can do
    $db = DBManagerFactory::getInstance();
    $query = "SELECT * FROM contracts WHERE id = '$record' and account_id = '$parent_id'";
    $result = $db->query($query, true,"greska");
    $result = $db->fetchByAssoc($result);
    $quantity = $result['broj_slucajeva'];
    return $quantity; //value of this variable will be shown in subpanel
    Last edited by eitrix; 2010-08-17 at 11:46 AM.
    CRM Software Engineer
    Eontek -

  2. #2
    rakeshray is offline Sugar Community Member
    Join Date
    Jun 2010
    Hyderabad (India)

    Default Re: custom field in subpanel

    Hi ,

    Nice ! thanks for sharing with us !

    Rakesh Ray

  3. #3 Guest

    Thumbs up Thankx a lot

    Thankx a lot for sharing the idea.

    Keep it up!

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. How to add custom field to subpanel
    By dompirrota in forum Developer Help
    Replies: 6
    Last Post: 2011-07-29, 09:14 PM
  2. Add custom field to subpanel
    By anjireddy987 in forum Developer Help
    Replies: 2
    Last Post: 2010-03-12, 03:36 AM
  3. custom field in a subpanel
    By carlaa in forum Developer Help
    Replies: 1
    Last Post: 2009-07-23, 07:53 PM
  4. Custom field on a subpanel
    By arasdeveloper2 in forum Help
    Replies: 3
    Last Post: 2009-04-24, 02:55 PM
  5. how to add a custom link to a subpanel field
    By tooth_decay in forum Developer Help
    Replies: 3
    Last Post: 2005-12-06, 09:00 PM


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts