SugarCRM one page control two modules (editview. php)

Source: Internet
Author: User
Purpose: To save two modules (two tables) with a Save button in editview)
Solution:
1. Write at the end of the editview. php file of the master table Module
Require_once ('Les les/bw_Consignments/editpanels/editview. php'); // execute the editview. php file of the sub-Table module.
2. Create an editpanels folder in the sub-Table module.
Copy the editview. php editview.html Forms. php file to this folder.
3. Modify the editpanels/EditView. php file
(1) require_once ('Les les/bw_Consignments/language/zh_cn.lang.php '); // write this sentence in the file header to introduce the $ mod_strings [] Array
4. The editpanels/EditView.html template can be adjusted as needed
(1) Remove save cancel button to delete the following code
<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) Remove <form name = "EditView" method = "post" action = "index. php"> </form> because the form is not required.
(3) Remove the following code
<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>
Because these controls form submission, and the form is no longer required, these are also not needed, and these conflicts with the main table Module

5. Modify the editpanels/Forms. php file.
Function get_new_record_form method name changed to get_new_record_form1
Function get_validate_record_js method name changed to get_validate_record_js1
Cause: This method is called by both modules on the same page to prevent duplicate names.

6. Submit and save
Principle: The two modules are merged into a form for submission. The sub-Table module is still saved by the sub-module.
Save. php of the primary table Module
$ Return_id = $ sugarbean-> id; \
$ Temp_id = $ return_id; // because $ return_id is saved by the sub-Table module, $ temp_id is used.
Require_once ('Les les/bw_Consignments/Save. php'); // execute the sub-Table module Save. php
// HandleRedirect ($ return_id, 'bw _ Msg_MT3101s '); // the original one, no longer needed
HandleRedirect ($ temp_id, 'bw _ Msg_MT3101s '); // page Jump

Note: After the sub-table is saved, the redirection should be removed.
SaveFormBase. php
// If ($ redirect ){
// HandleRedirect ($ return_id, "bw_Consignments ");
//} Else {
// Return $ focus;
//}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.