将Country TextField更改为SugarCRM中的Dropdown

Rav*_*pra 7 php sugarcrm

我想将"地址"面板中的"国家/地区"TextField更改为下拉列表.我怎样才能做到这一点?

Kar*_*ill 10

SugarCRM 6.x:

1)为您的国家/地区字段创建或更新vardef:

定制/扩展/模块/ [MODULE_NAME] /Ext/Vardefs/custom_primary_address_country.php

$dictionary['<MODULE_NAME>']['fields']['primary_address_country']['comments']='Country for primary address';
$dictionary['<MODULE_NAME>']['fields']['primary_address_country']['group']='primary_address';
$dictionary['<MODULE_NAME>']['fields']['primary_address_country']['options']='countries_dom';
$dictionary['<MODULE_NAME>']['fields']['primary_address_country']['type']='enum';
Run Code Online (Sandbox Code Playgroud)

2)复制地址字段的编辑视图模板...

包括/ SugarFields /场/地址/ EditView.tpl

进入/ custom中的新目录:

定制/包含/ SugarFields /场/ [CUSTOM_TYPE_NAME] /EditView.tpl

3)编辑模板并更改:

<input type="text" name="{{$country}}" id="{{$country}}" size="{{$displayParams.size|default:30}}" {{if !empty($vardef.len)}}maxlength='{{$vardef.len}}'{{/if}} value='{$fields.{{$country}}.value}' tabindex="{{$tabindex}}">
Run Code Online (Sandbox Code Playgroud)

至:

<select name="{{$country}}" width="{{$displayParams.size|default:30}}" id="{{$country}}" title="{{$vardef.help}}" tabindex="{{$tabindex}}" {{if isset($displayParams.script)}}{{$displayParams.script}}{{/if}}>
{if isset($fields.{{$country}}.value) && $fields.{{$country}}.value != ''}
 {html_options options=$fields.{{$country}}.options selected=$fields.{{$country}}.value}
{else}
 {html_options options=$fields.{{$country}}.options selected=$fields.{{$country}}.default_value}
{/if}
</select>
Run Code Online (Sandbox Code Playgroud)

4)在custom/modules/[MODULE_NAME] /metadata/editviewdefs.php中,将"type"更改为新的自定义类型名称.

    0 => 
      array (
        'name' => 'primary_address_country',
        'hideLabel' => true,
        'type' => '<CUSTOM_TYPE_NAME>',
        'displayParams' => 
        array (
          'key' => 'primary',
          'rows' => 2,
          'cols' => 30,
          'maxlength' => 150,
        ),
        'label' => 'LBL_PRIMARY_ADDRESS_COUNTRY',
      ),
Run Code Online (Sandbox Code Playgroud)

5.对于要从文本字段更改为下拉列表的每个国家/地区字段,重复步骤1和4.对于之前输入的值,您需要确保它们与'countries_dom'中的值匹配.

在SugarCRM 7.x中,这更简单,您只需要执行第1步.