CE 6.5.4
I'm trying to override the check_form function in: /include/javascript/sugar_3.js with my own.
I've read this post:
overriding Save button : after ajax validation save editView form
It was a lot of help but apparently she left some critical stuff out.
As it is, if I click the Save button it should just show me an alert saying 'Test' and not save the record.
Instead it just saves the record.
How can I make this work?
I added a file: custom/modules/Contacts/js/CkContactTaken.js
<code>
function ckContactTaken()
{
alert("Test");
return false;
}
function check_form(formname)
{
bValid = false;
if(typeof(siw)!='undefined'&&siw&&typeof(siw.selectingSomething)!='undefined'&&siw.selectingSomething) return false;
bValid = validate_form(formname,'');
if(!bValid) return false;
if(!ckContactTaken()) return false;
return true;
}
</code>
I added another file to try to get CE to 'load' my js file:
custom/modules/Contacts/metadata/editviewsdef.php
<code>
$viewdefs['Contacts']['EditView']['templateMeta']['includes'] =
array (
array (
'file' => 'custom/modules/Contacts/js/CkContactTaken.js',
),
);
</code>
I'm trying to override the check_form function in: /include/javascript/sugar_3.js with my own.
I've read this post:
overriding Save button : after ajax validation save editView form
It was a lot of help but apparently she left some critical stuff out.
As it is, if I click the Save button it should just show me an alert saying 'Test' and not save the record.
Instead it just saves the record.
How can I make this work?
I added a file: custom/modules/Contacts/js/CkContactTaken.js
<code>
function ckContactTaken()
{
alert("Test");
return false;
}
function check_form(formname)
{
bValid = false;
if(typeof(siw)!='undefined'&&siw&&typeof(siw.selectingSomething)!='undefined'&&siw.selectingSomething) return false;
bValid = validate_form(formname,'');
if(!bValid) return false;
if(!ckContactTaken()) return false;
return true;
}
</code>
I added another file to try to get CE to 'load' my js file:
custom/modules/Contacts/metadata/editviewsdef.php
<code>
$viewdefs['Contacts']['EditView']['templateMeta']['includes'] =
array (
array (
'file' => 'custom/modules/Contacts/js/CkContactTaken.js',
),
);
</code>
I had to copy the file editviewdefs.php from the:
<sugarcrm>/modules/Contacts/metadata
folder to:
<sugarcrm>/custom/modules/Contacts/metadata
Then I had to add the code (above) to the bottom of that file pointing to my javascript file:
I notice that if 'includes' were already added to
$viewdefs['Contacts']['EditView']['templateMeta']
I would need to take care to add another array to includes.
As it is, it overwrites any existing includes (none exist in that particular file).