sugarCRM如何填充下拉列表

时间:2012-09-07 15:14:07

标签: php sugarcrm

我正在使用SugarCRM v6.5,我非常新手。 在Leads中,我想在地址类型中添加一个字段来指示地址类型(即办公室,家庭,......)。因此在工作室中我创建了这个字段“type_address”作为一个简单的下拉列表(不知道英语中的术语,法语中的“listeàchoixsimple”)并且我指出了用于填充它的选项。到目前为止,没关系,如果我在表单上显示它,它会正确填充。但是我想在地址字段中添加它,所以我打开了include \ SugarFields \ Fields \ Address \ fr_FR.EditView.tpl并添加了这样一行:

<tr style="background-color: yellowgreen;">
<td valign="top" width='25%' scope='row' ><label for="{{$typeaddr}}">{sugar_translate label='LBL_{{$key}}_ADRESS_TYPE' module='{{$module}}'}:</label>
{if $fields.{{$typeaddr}}.required || {{if $typeaddr|lower|in_array:$displayParams.required}}true{{else}}false{{/if}}}
<span class="required">{$APP.LBL_REQUIRED_SYMBOL}</span>
{/if}
</td>
<td>
<select name="{{$typeaddr}}" id="{{$typeaddr}}" title=''  >
   {html_options options=$fields.{{$typeaddr}}.options }
</select>
</td>
</tr>

并在模板顶部放置:

{{assign var="typeaddr" value=$displayParams.key|cat:'_adress_type_c'}}

显示行,标签正常,但下拉列表不会填充。 我试着在中指出选项列表 \定制\延期\模块\信息\分机\ Vardefs \ sugarfields_primary_adress_type_c.php 像这样:

$dictionary['Lead']['fields']['primary_adress_type_c']['type'] = 'base';
$dictionary['Lead']['fields']['primary_adress_type_c']['options'] = 'list_name_as_created_in_studio';

我也试过把它放在\ custom \ modules \ Leads \ metadata \ editviewdefs.php

0 => 
      array (
        'name' => 'primary_adress_type_c',
        'studio' => 'visible',
        'label' => 'LBL_PRIMARY_ADRESS_TYPE',
        'type' => 'base',
        'options' => list_name_as_created_in_studio',
      ),

我尝试了enum和base。诀窍是,即使我把'枚举'和一系列选项,它也不会填充。

我看不出我可以干涉哪里让它发挥作用,我肯定忘记做某事。

欢迎任何帮助,甚至是手册的链接(我阅读它并没有找到任何帮助,但我可能会错过一些东西)

1 个答案:

答案 0 :(得分:1)

在文件include\SugarFields\Fields\Address\fr_FR.EditView.tpl中,替换:

<select name="{{$typeaddr}}" id="{{$typeaddr}}" title=''  >
   {html_options options=$fields.{{$typeaddr}}.options }
</select>

with:

{html_options name=primary_adress_type_c options=$primary_adress_type_c_options selected=$fields.primary_adress_type_c.value}

使用内容

创建新文件custom/modules/Leads/views/view.edit.php
<?php
require_once('include/MVC/View/views/view.edit.php');
class LeadsViewEdit extends ViewEdit{

    public function LeadsViewEdit(){
        parent::ViewEdit();
    }

  public function preDisplay() {
    parent::preDisplay();
    $this->ss->assign('primary_adress_type_c_options', $GLOBALS['app_list_strings']['list_name_as_created_in_studio']);
  }

    public function display(){
        parent::display();
    }
}
?>
相关问题