繁体   English   中英

如何在vtiger crm中为州名添加下拉框

[英]How to add a dropdown box for state name in vtiger crm

我有一个表单,我必须添加一个下拉状态名称字段,以便用户可以从该选择框中选择他们想要的状态名称。

我怎样才能做到这一点?

您可以使用vtlib库。

这是我们如何使用vtlib在Accounts模块中创建一个州名称下拉框

<?php
$Vtiger_Utils_Log = true;
include_once('vtlib/Vtiger/Menu.php');
include_once('vtlib/Vtiger/Module.php');
$module = Vtiger_Module::getInstance('Accounts');
$infoBlock = Vtiger_Block::getInstance('LBL_ACCOUNT_INFORMATION', $module);
$stateField = Vtiger_Field::getInstance('state', $module);
if (!$stateField) {
    $stateField = new Vtiger_Field();
    $stateField->name = 'state';
    $stateField->label = 'State';
    $stateField->columntype = 'VARCHAR(100)';
    $stateField->uitype = 16;
    $stateField->typeofdata = 'V~O';
    $infoBlock->addField($stateField);
    $stateField->setPicklistValues(array('Kerala', 'Karnataka', 'Maharashtra', 'Manipur'));

}

在该数组中添加其余的状态列表。

希望这可以帮助。

假设你有像mysql这样的数据库。

  • 创建表statestate_idstate_namestate_abbr
  • state表中获取状态(写一个函数来获取状态)
  • 使用php脚本迭代选择框的选项,例如:

     <select name="state"> <?php // At this point you should have a recordset $rsstate which fetches all the records from the state table while($rowState = mysql_fetch_array($rsState)) { ?> <option value=<?php echo $rowState["state_abbr"] ?>><?php echo $rowState["state_name"]; ?></option> <?php } ?> </select> 

只需转到管理面板并添加一个选项列表。 它非常简单。

假设你有像mysql这样的数据库。

  • 创建表状态(state_id,state_name,state_abbr)
  • 从状态表中获取状态(写一个函数来获取状态)
  • 使用php脚本示例迭代选择框的选项:

      <select name="state"> <?php *// At this point you should have a recordset $rsstate which fetches all the records from the state table* while($rowState = mysql_fetch_array($rsState)){?> <option value=<?php echo $rowState["state_abbr"]?>><?php echo $rowState["state_name"]; ?></option> <?php }?> </select> 

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM