Creating a file type field in the sugarcrm user module

I have a custom Sample Management module. I want to create a file type field in editviewdef.php so that I can upload the file and load it from the verbose view when necessary. Will someone tell me how to do this?

+4
source share
2 answers

What you need to do is create your own SugarField type:

  • Create a new folder with the name of the field type in include / SugarFields / Fields
  • In this folder, you need to create a .tpl file to describe how the field is configured for each type of view (so that you have EditView.tpl, DetailView.tpl and any other views that you would use the field for). I would look in / include / SugarFields / Fields / Text for a good example of what settings you should create.
  • Create a new field with this type, or use vardefs or the field_meta_data table (for custom fields) to change the field type from the existing type to the new type.

I can definitely make sure that there is a file field type like from SugarCRM 6.4.1, once you determine how the field is laid out, you should be able to use it without any problems with the rest of CRM.

+1
source

If you create a module through the Builder module, just add 'file' => 1 to the 'templates' array in the $ config (config.php) variable. Then you can add a new file upload field to editviewdefs.php:

1 => array ( 'name' => 'uploadfile', 'displayParams' => array ( 'onchangeSetFileNameTo' => 'document_name', ), ), 

Remember to add form and javascript elements to the templateMeta array in editviewdefs.php:

  'form' => array ( 'enctype' => 'multipart/form-data', 'hidden' => array ( ), ), 'javascript' => '<script type="text/javascript" src="include/javascript/popup_parent_helper.js?s={$SUGAR_VERSION}&c={$JS_CUSTOM_VERSION}"></script> <script type="text/javascript" src="include/javascript/sugar_grp_jsolait.js?s={$SUGAR_VERSION}&c={$JS_CUSTOM_VERSION}"></script> <script type="text/javascript" src="modules/Documents/documents.js?s={$SUGAR_VERSION}&c={$JS_CUSTOM_VERSION}"></script>', 

You also need to add the uploadfile field to the detailvidefs.php file:

  1 => array ( 'name' => 'uploadfile', 'displayParams' => array ( 'link' => 'uploadfile', 'id' => 'id', ), ), 

Hope this helps!

+1
source

Source: https://habr.com/ru/post/1346670/


All Articles