SugarCRM 一个页面控制两个模块(editview.php)
目的:在editview中一个保存按钮,保存两个模块(两张表)
解决方案:
1.在主表模块的editview.php文件最后写
require_once('modules/bw_Consignments/editpanels/editview.php'); //执行子表模块的editview.php文件
2.在子表模块中新建editpanels文件夹
将editview.php editview.html Forms.php 文件复制到此文件夹下
3.修改editpanels/EditView.php文件
(1) require_once('modules/bw_Consignments/language/zh_cn.lang.php');//在文件头部写此句,用于引入$mod_strings[]数组
4.editpanels/EditView.html 可根据需求调整模板
(1)去除保存 取消按钮 删除以下代码
<input type="submit" name="button" value=" {APP.LBL_SAVE_BUTTON_LABEL} "
class="button" tabindex="5"
onclick="this.form.action.value='Save'; return check_form('EditView');"
title="{APP.LBL_SAVE_BUTTON_TITLE}" accesskey="{APP.LBL_SAVE_BUTTON_KEY}"/>
<input type="submit" name="button" value=" {APP.LBL_CANCEL_BUTTON_LABEL} "
class="button" tabindex="6"
onclick="this.form.module.value='{RETURN_MODULE}'; this.form.action.value='{RETURN_ACTION}'; this.form.record.value='{RETURN_ID}';"
title="{APP.LBL_CANCEL_BUTTON_TITLE}"
accesskey="{APP.LBL_CANCEL_BUTTON_KEY}"/>
<td align="right" nowrap><span class="required">{APP.LBL_REQUIRED_SYMBOL}</span> {APP.NTC_REQUIRED}</td>
< td align="right">{ADMIN_EDIT}</td>
(2)去除<form name="EditView" method="post" action="index.php"> </form> 因为表单这个表单不需要了
(3)去除下面代码
<table width="100%" cellpadding="0" cellspacing="0" border="0">
<tr>
<input type="hidden" name="module" value="bw_Consignments" />
<input type="hidden" name="record" value="{ID}" />
<input type="hidden" name="action" value="" />
<input type="hidden" name="return_module" value="{RETURN_MODULE}" />
<input type="hidden" name="return_id" value="{RETURN_ID}" />
<input type="hidden" name="return_action" value="{RETURN_ACTION}" />
</tr>
</table>
因为这些是控制表单提交的,表单已经不需要,所以这些也不用了,而且这些与主表模块冲突
5.修改editpanels/Forms.php 文件
function get_new_record_form 方法名修改为 get_new_record_form1
function get_validate_record_js 方法名修改为 get_validate_record_js1
原因: 因为两个模块同一页时,两个模块均调用了此方法,为了防止重名
6.提交保存
原理:将两个模块合成为一个表单一同提交,子表模块仍然由子模块执行保存.
主表模块的save.php
$return_id = $sugarbean->id; \\此句下面写
$temp_id=$return_id;//因为$return_id已为子表模块保存的id 所以用$temp_id
require_once('modules/bw_Consignments/Save.php');//执行子表模块Save.php
//handleRedirect($return_id,'bw_Msg_MT3101s');//原来的,不用了
handleRedirect($temp_id,'bw_Msg_MT3101s');//页面跳转
注意: 子表保存后跳转应去掉
SaveFormBase.php
//if ($redirect) {
// handleRedirect($return_id,"bw_Consignments" );
//} else {
// return $focus;
//}
分类:
SugarCRM
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
· 理解Rust引用及其生命周期标识(上)
· 浏览器原生「磁吸」效果!Anchor Positioning 锚点定位神器解析
· 没有源码,如何修改代码逻辑?
· 分享4款.NET开源、免费、实用的商城系统
· 全程不用写代码,我用AI程序员写了一个飞机大战
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· 白话解读 Dapr 1.15:你的「微服务管家」又秀新绝活了
· 上周热点回顾(2.24-3.2)