AnsweredAssumed Answered

How can I add panels and fields to existing module layouts via manifest?

Question asked by Ramblin Ramblin on Feb 24, 2014
Latest reply on Apr 12, 2018 by Matthew Poer
I had asked, in the old forum, how to add panels and fields to the panels in an existing module when installing a package with a manifest file.  I did not want to override any cusomtizations already performed on the detailview or editview of the existing module.

Well, thanks to Matthew Poer, I have now discovered a hidden gem in the SugarCRM code that makes the task very easy and I wanted to share it with users of this new forum.

So, to add a panel with fields to the detailview of the Accounts module (I show a simple example with just two existing fields, but you can extend it to include any fields, including new custom fields added via the manifest file):

1) Add the language definition for the name of the new panel into a file in
(In my case I added a panel called lbl_detailview_panel1 - I sugggest you use a more unique name for yours to make sure there is no overlap in naming of panels)

2) Add, into the post_install.php file in the scripts directory in your zipped package:

function post_install()
  // Debug point - checking to see if get to post_install script
  echo "Made it to the post_install script.<br />";

  // Use the ParserFactory to edit the view arrays
  // Fetch the existing view into an array called $view_array
  $view_array = ParserFactory::getParser('detailview','Accounts');
  // Declare the additional content
  $new_content = array
   0 => array
    0 => array
     'name' => 'created_by_name',
     'label' => 'LBL_CREATED',
    1 => array
     'name' => 'modified_by_name',
     'label' => 'LBL_MODIFIED_NAME',
  // Add the new content to the desired section of the view array
  $view_array->_viewdefs['panels']['lbl_detailview_panel1'] = $new_content;
  //Save the layout

Install the package and you have the new panel in Accounts with the fields you defined.

Thanks Matthew