アカウントモジュールに会社名を入力するときに会社データを取得するために使用される VTiger 6.4.0 拡張モジュールに取り組んでいます。
モジュールはほぼ完成しています。API からデータを取得し、JQuery を使用して入力フィールドに入力します。
しかし問題は、アカウント情報の既存のフィールドに関連しないデータがあることです。そのため、新しいカスタム フィールドをいくつか作成しようとしています。
拡張機能モジュール内からアカウント モジュールのカスタム フィールドを作成する方法がわかりません。
グーグルで調べて、stackoverflow に関するいくつかの投稿を見ました。
コードの次の部分を思いつきましたが、これは機能していないようです。
public function addKvkfield(){
$module = new Vtiger_Module();
$module->name = 'Accounts';
$module = $module->getInstance('Accounts');
$blockInstance = new Vtiger_Block();
$blockInstance->label = 'LBL_ACCOUNT_INFORMATION';
$blockInstance = $blockInstance->getInstance($blockInstance->label,$module);
$fieldInstance = new Vtiger_Field();
$fieldInstance->name = 'KvKNummer';
$fieldInstance->table = $module->basetable;
$fieldInstance->column = 'kvknummer';
$fieldInstance->columntype = 'VARCHAR(100)';
$fieldInstance->uitype = 2;
$fieldInstance->typeofdata = 'V~M';
$blockInstance->addField($fieldInstance);
}
vtlib_handler module.postinstall で addKvkfield 関数が呼び出されています (これが拡張モジュール内でこれを行う正しい方法である場合、情報は見つかりませんでした)
vtlibhandler:
function vtlib_handler($modulename, $event_type) {
global $log;
if($event_type == 'module.postinstall') {
$this->addJSLinks();
$this->createConfigTable();
$this->addSettingsMenu();
$this->addKvkfield();
$this->updateLabels();
// TODO Handle post installation actions
} else if($event_type == 'module.disabled') {
// TODO Handle actions when this module is disabled.
} else if($event_type == 'module.enabled') {
// TODO Handle actions when this module is enabled.
} else if($event_type == 'module.preuninstall') {
// TODO Handle actions when this module is about to be deleted.
} else if($event_type == 'module.preupdate') {
// TODO Handle actions before this module is updated.
} else if($event_type == 'module.postupdate') {
$this->updateLabels();
// TODO Handle actions after this module is updated.
}
}
うまくいけば、誰かが私に正しい方向へのプッシュを与えることができます.
前もって感謝します :)