开发者

making a file type field in sugarcrm custom module

i have a custom module Sample Management. I want to create a file type field in editviewdef.php so that i can upload the file and download it from the detailed view whenever needed. Would anyone tell me the st开发者_Python百科eps how to proceed for this task?


If you are creating the module through Module Builder, just add 'file' => 1, to the 'templates' array in $config variable (config.php). Then you'll be able to add a new upload file field to your editviewdefs.php:

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

Don't forget to add the 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 detailvidefs.php:

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

Hope this helps!


What you need to do is create a custom SugarField type by:

  1. Creating a new folder with the name of the field type in include/SugarFields/Fields
  2. Within that folder, you need to create a .tpl file to describe how the field is setup for each view type (so you would have an EditView.tpl, DetailView.tpl, and any other views that you would be using that field for). I would look in the /include/SugarFields/Fields/Text for a good example of what tpls you should create.
  3. Create a new field with that type, or by using vardefs or the field_meta_data table (for custom fields) change the field type from it's existing type to your new type.

I can definitely verify that there is a file field type as of SugarCRM 6.4.1, once you define how the field is laid out, you should be able to use it seamlessly with the rest of the CRM.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜