SugarCRM 一個頁面控制兩個模組(editview.php)

來源:互聯網
上載者:User
目的:在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;
//}

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.