Assume your module name as ‘ABC_XXX’.
Create the file or edit the existing file
/custom/modules/ABC_XXX/metadata/editviewdefs.php
and include the code below
$module_name = 'ABC_XXX'; $viewdefs [$module_name] = array ( 'EditView' => array ( 'templateMeta' => array ( 'form' => array( 'buttons' => array ( 0 => array( 'customCode' => '<input title="Save [Alt+S]" accessKey="S" onclick="this.form.action.value=\'Save\'; return check_custom_data();" type="submit" name="button" value="'.$GLOBALS['app_strings']['LBL_SAVE_BUTTON_LABEL'].'">', ), 1 => array( 'customCode' => '<input title="Cancel [Alt+X]" accessKey="X" onclick="this.form.action.value=\'index\'; this.form.module.value=\''.$module_name.'\'; this.form.record.value=\'\';" type="submit" name="button" value="'.$GLOBALS['app_strings']['LBL_CANCEL_BUTTON_LABEL'].'">' ) ) ), 'includes'=> array( array('file'=>'custom/modules/ABC_XXX/customJavascript.js'), ), ), );
Create a javascript file at
custom/modules/ABC_XXX/ named customJavascript.js
and include the code below
function check_custom_data() { alert('here'); if (condition) { return false; } return check_form('EditView'); }
Related Articles
- SugarCRM Leaders to Present at OSCON Open Source Convention 2010 (eon.businesswire.com)
- RhoLogic launches SugarCRM smartphone app for the iPhone and Android (intomobile.com)
- SugarCRM Announces Sugar Platform Edition for the OEM Market (eon.businesswire.com)
- SugarCRM woos developers, thinks social (v3.co.uk)
- Joelle Nebbe (iphigenie): vtiger CRM 5.2.0 Released. (vtiger.com)
- SugarCRM Adds Certified Chinese Language Support (eon.businesswire.com)
- Sugar CRM is Now Hype, Technology, Trend and Coolness Compliant (readwriteweb.com)
Doesn’t work on Sugar CRM Enterprise 6.5.15 Windows 7
LikeLike
Interesting read, perhaps the best article iv’e browse today. We learn everyday cheers to you!
LikeLike
Exceptional page and even quick to help you comprehend justification. Exactly how can As i continue acquiring concur to help you place part belonging to the guide inside new newssheet? Getting right credit standing you that journalist and even backlink with the internet site won’t even be a concern.
LikeLike
I don’t even know how I ended up here, but I thought this post was good. I don’t know who you are but certainly you’re going to a famous blogger if you aren’t already 😉 Cheers!
LikeLike
fantastic web site. Keep doing
LikeLike
Great article. I commitment certainly due this article with my friends. Thanks for the info.
LikeLike
Looking forward to reading more. Great blog.Really looking forward to read more. Keep writing.
LikeLike
Great blog . . . I’m kind of a personal development junkie and was looking around on google blogsearch for stuff related to that. Definitely grabbed the rss feed and looking forward to reading more!
LikeLike
Hello.
For editview works perfectly, but doesn’t work in quickcreatedefs :(. I use sugar 6.1.3 CE. Any thoughts on this will be appreciated.
Thanks.
LikeLike
Please post what all changes you have done for the quickcreatedefs. We will have a look and solve it out.
Thanks
LikeLike
I want to add javascript on save button and tried as explained in this blog.
quickcreatedefs.php
‘customCode’ =>
”,
…….
‘file’ => ‘modules/test_test/change.php’,
but doesn’t work.
The only way I managed to get him to go was to change the file /include/Smarty/plugins/function.sugar_button.php like that:
case “SUBPANELSAVE”:
$view = $view == ‘QuickCreate’ ? “form_SubpanelQuickCreate_{$module}” : $view;
return ‘{if $bean->aclAccess(“save”)}{/if} ‘;
That would be a solution but I think this not is customizing upgrade safe and for each module must change the structure.
LikeLike
I want to add javascript on save button and tried as explained in this blog.
quickcreatedefs.php
‘customCode’ =>
‘ <input title=”Save [Alt+S]” accessKey=”S” onclick=”this.form.action.value=\’Save\’;return check_custom_data();” type=”submit” name=”button” value=”‘.$GLOBALS[‘app_strings’][‘LBL_SAVE_BUTTON_LABEL’].'”>’,
…….
‘file’ => ‘modules/test_test/change.php’,
but doesn’t work.
The only way I managed to get him to go was to change the file /include/Smarty/plugins/function.sugar_button.php like that:
case “SUBPANELSAVE”:
$view = $view == ‘QuickCreate’ ? “form_SubpanelQuickCreate_{$module}” : $view;
return ‘{if $bean->aclAccess(“save”)}<input title=”{$APP.LBL_SAVE_BUTTON_TITLE}” accessKey=”{$APP.LBL_SAVE_BUTTON_KEY}” class=”button” onclick=”this.form.action.value=\’Save\’;if(check_custom_data(check_form(\”.$view.’\’)))return SUGAR.subpanelUtils.inlineSave(this.form.id, \” . $params[‘module’] . ‘_subpanel_save_button\’);return false;” type=”submit” name=”‘ . $params[‘module’] . ‘_subpanel_save_button” id=”‘ . $params[‘module’] . ‘_subpanel_save_button” value=”{$APP.LBL_SAVE_BUTTON_LABEL}”>{/if} ‘;
That would be a solution but I think this not is customizing upgrade safe and for each module must change the structure.
LikeLike
The file should be a JS file. include that file on the custom folder. the function you calling should be a JS function.
Example
includes’=> array(
array(‘file’=>’custom/modules/ABC_XXX/customJavascript.js’),
),
LikeLike
Thanks, but still is not working.
change.js
function myjs(){ alert(‘ok’) }.
When I’m in editview and press the save button works fine, but when I’m in quickcreate don’t appear alert popup
LikeLike
Thanks, but still is not working
‘file’ => ‘modules/test_test/change.js’,
change.js
function myjs()
{
alert(‘ok’);
}
Editview works fine when I press the save button, but in quickcreate does not appear popup alert.
Thanks
LikeLike