提供 Salutation 和 Firstname 与 vtiger 6.4 uitype=55 的组合

provide a combination of Salutation and Firstname with vtiger 6.4 uitype=55

在自定义模块中,我想创建称呼和名字字段的组合,与 Leads 模块中的完全一样。我正在使用 vtlib 创建我的模块。我创建了以下字段:

 $field2  = new Vtiger_Field();
 $field2->name = 'firstname';
 $field2->label= 'Firstname';
 **$field2->uitype= 55;**
 $field2->column = $field2->name;
 $field2->columntype = 'VARCHAR(255)';
 $field2->typeofdata = 'V~O'; // Varchar Optional field
 $block->addField($field2);

这没有按预期工作,只创建了一个没有称呼字段的文本字段。

https://wiki.vtiger.com/index.php/UI_Types 我们可以读到 uitype=55:

"This uitype provides a combination of Salutation and Firstname. The Salutation field is a dropdown while the Firstname field is a single line textfield which changes its colour on selection."

所以我想知道我是否必须为称呼创建一个新的选择列表(我们可以重复使用现有的吗?),以及如何将它们与唯一的名字标签放在一行中。

有什么想法吗?

此致

好的,知道了。在 vtlib 脚本中,我添加了如下内容:

  $field0  = new Vtiger_Field();
  $field0->name = 'salutationtype';
  $field0->label= 'Salutation';
  // This uitype provides a combination of Salutation and Firstname. The Salutation field is a dropdown w$
  $field0->uitype= 55; // A single line textfield. Changes colour when selected.
  $field0->column = 'salutation';
  $field0->columntype = 'VARCHAR(20)';
  $field0->typeofdata = 'V~O'; // Varchar Optional field
  $field0->displaytype = 3; // Hide from view
  $block->addField($field0);

  $field1  = new Vtiger_Field();
  $field1->name = 'firstname';
  $field1->label= 'First Name';
  // This uitype provides a combination of Salutation and Firstname. The Salutation field is a dropdown w$
  $field1->uitype= 55; // A single line textfield. Changes colour when selected.
  $field1->column = $field1->name;
  $field1->columntype = 'VARCHAR(255)';
  $field1->typeofdata = 'V~O'; // Varchar Optional field
  $block->addField($field1);

然后我创建了以下文件:modules/MyModule/views/Edit.php

class MyModule_Edit_View extends Vtiger_Edit_View {

  public function process(Vtiger_Request $request) {
    $moduleName = $request->getModule();
    $recordId = $request->get('record');
    $recordModel = $this->record; 

    if(!$recordModel){
      if (!empty($recordId)) {
        $recordModel = Vtiger_Record_Model::getInstanceById($recordId, $moduleName);
      } else {
          $recordModel = Vtiger_Record_Model::getCleanInstance($moduleName);
        }
    }

    $viewer = $this->getViewer($request);

    $salutationFieldModel = Vtiger_Field_Model::getInstance('salutationtype', $recordModel->getModule());
    $salutationType = $request->get('salutationtype');
    if(!empty($salutationType)){ 
      $salutationFieldModel->set('fieldvalue', $request->get('salutationtype')); 
    } 
    else{ 
      $salutationFieldModel->set('fieldvalue', $recordModel->get('salutationtype')); 
    } 
    $viewer->assign('SALUTATION_FIELD_MODEL', $salutationFieldModel);
    parent::process($request);
  }
}

现在它按预期工作了。