wasky
9 July 2019 08:48
#1
To reference a full form edit within the addToValidate function, i use EditView , which works perfectly
addToValidate('EditView','industry_c','varchar',true,'{$mod_strings['LBL_INDUSTRY']}');
If i want to do field validation using the addToValidate function within the quick create.
What form name do i use?
QuickCreate
QuickCreateView
??
You have to inspect element of the form for that specific subpanel that you want to apply.
For example. for Task module it is.
form_SubpanelQuickCreate_Tasks.
So the pattern is like form_SubpanelQuickCreate_Contacts, form_SubpanelQuickCreate_FP_events, etc…
1 Like
wasky
10 July 2019 12:45
#3
Thanks Urdvatech,
$mod_strings doesnt seem to still have the lable. I am trying to validate fields according to a value of a drop down.
My addToValidate is as follows:
addToValidate('form_SubpanelQuickCreate_Cases','industry_c','varchar',true,'{$mod_strings['LBL_INDUSTRY']}');
$('#industry_c_label').html('{$mod_strings['LBL_INDUSTRY']}: <font color="red">*</font>');
This works fine on the full form, but having issues on the QuickCreate Form
Hello,
Make sure you have defined the global variable as $mod_strings.
like, global $mod_strings
wasky
10 July 2019 12:59
#6
Complete Custom Classic Class
class CustomCasesViewClassic extends ViewClassic
{
public function display()
{
global $mod_strings;
$jsscript = <<<EOQ
<script>
$('#type_c').change(function() {
makerequired();
function makerequired()
{
var ticket_type = $("#type_c").val();
if((ticket_type === 'test')){
var form = document.getElementById('form_SubpanelQuickCreate_Cases');
console.log(form);
addToValidate('form_SubpanelQuickCreate_Cases','industry_c','varchar',true,'{$mod_strings['LBL_INDUSTRY']}');
$('#industry_clabel').html('{$mod_strings['LBL_INDUSTRY']}: <font color="red">*</font>');
}
}
makerequired();
</script>
EOQ;
parent::display();
echo $jsscript;
}
}
Try this.
SUGAR.language.get("", “LBL_REMOVING_ATTACHMENT”);
1 Like
wasky
10 July 2019 13:14
#9
Something like this?
var industryLabel = SUGAR.language.get(‘Cases’, ‘LBL_INDUSTRY’);
addToValidate(‘form_SubpanelQuickCreate_Cases’,‘industry_c’,‘varchar’,true,‘industryLabel’);
$(’#industry_c_label ’).html(’{$mod_strings[‘LBL_INDUSTRY’]}: *’);
addToValidate(‘form_SubpanelQuickCreate_Cases’,‘industry_c’,‘varchar’,true,‘industryLabel’);
industryLabel should be used as variable not string.
Oh, you got it. My answer was a little late.
Cheers!!