在 SugarCRM 自定义模块中创建文件类型字段

发布于 2024-10-29 12:07:22 字数 95 浏览 0 评论 0原文

我有一个自定义模块样本管理。我想在 editviewdef.php 中创建一个文件类型字段,以便我可以在需要时上传文件并从详细视图下载它。有人能告诉我如何完成这项任务的步骤吗?

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 steps how to proceed for this task?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

再浓的妆也掩不了殇 2024-11-05 12:07:22

如果您通过模块生成器创建模块,只需添加 'file' => 1、到 $config 变量 (config.php) 中的“templates”数组。然后,您将能够将新的上传文件字段添加到 editviewdefs.php:

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

不要忘记将表单和 javascript 元素添加到 editviewdefs.php 中的 templateMeta 数组:

  '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>',

您还需要将 uploadfile 字段添加到detailvidefs。 php:

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

希望这有帮助!

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!

枕头说它不想醒 2024-11-05 12:07:22

您需要做的是通过以下方式创建自定义 SugarField 类型:

  1. 在 include/SugarFields/Fields 中创建一个包含字段类型名称的新文件夹
  2. 在该文件夹中,您需要创建一个 .tpl 文件来描述如何设置该字段每种视图类型(因此您将拥有 EditView.tpl、DetailView.tpl 以及您将使用该字段的任何其他视图)。我会在 /include/SugarFields/Fields/Text 中查找您应该创建的 tpl 的一个很好的示例。
  3. 创建具有该类型的新字段,或者使用 vardefs 或 field_meta_data 表(对于自定义字段)将字段类型从现有类型更改为新类型。

我绝对可以验证 SugarCRM 6.4.1 中是否存在文件字段类型,一旦您定义了该字段的布局方式,您应该能够与 CRM 的其余部分无缝地使用它。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文