HOWTO: The many ways to customize the display of a field for the DetailView or EditView

Matthew Marum —  April 12, 2011 — 2 Comments

I’ve seen a lot of questions lately on the forums that ask about customizing how fields display on the metadata driven DetailViews and EditViews. There are a few different ways to approach this problem, depending upon the customization you are doing and in how many different places that the change need to be made. Here’s a quick overview.

  • To override the display of a single field in a single location, the easiest way to do this is by adding the ‘customCode’ attribute to the field definition in the viewdef file that you wish to change.
  • To change the display of all fields of the same type ( for example, if you wanted to change how all the relate fields displayed throughout the application ) the best choice is to make your customization in the custom/include/SugarFields/Fields/<fieldname>/ directory. Either make your customization to the EditView.tpl or DetailView.tpl, depending upon which field you wish to change. You can use this same procedure for customizing how fields display on the SearchForm or ListView as well.
  • If you want to change how a single field displays throughout the application, but don’t want to change the display for every field of that type in the application ( for example, you want to change how the assigned user name field appears on the Calls, Meetings, and Tasks views, but not change it across the board ) you’ll want to create a new SugarField type based upon the current field type. You may also want to do this if the custom code you wish to define for the display is quite complex, and involves a lot of smarty code. To do this, you’ll need to:
    • Create a new directory custom/include/SugarFields/Fields/<fieldname>/, where <fieldname> is the name of your newly created field.
    • Add the file SugarField<fieldname>.php, which defines the class SugarField<fieldname> that extends from the SugarField class you are looking to modify
    • Add in the EditView.tpl or DetailView.tpl to customize the display of your field
    • Update the ‘type’ field in each of field you want to change to <fieldname>, setting ‘dbType’ to what ‘type’ was previously set to.

After you make any of these customization, be sure to do a ‘Quick Rebuild and Repair’ so that they can take effect.

Matthew Marum


Matt is the Director of Developer Advocacy for SugarCRM. Previously he was an Engineer on Sugar 7 and a Solutions Architect for the OEM program. He is also an avid trail runner, Boston Marathon qualifier and a karaoke aficionado.

2 responses to HOWTO: The many ways to customize the display of a field for the DetailView or EditView


    Big Thanks John.


    After styling my field in EditView, the field is non-editable. I need to edit this field

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s