AnsweredAssumed Answered

Add validation to custom field in Campaigns module

Question asked by Madhav Shenoy on Jun 2, 2015
Latest reply on Jun 3, 2015 by Emil Maran
    We're using Sugar version 7.2. We have a requirement to add a time field in the Campaigns module. For this I created a custom field using Studio called start time. Now since this was a free text field I had to add validations so only valid times were entered. I first made my changes in the Wizard by customising the WizardCampaignHeader.tpl in custom/modules/Campaigns/tpls/WizardCampaignHeader.tpl. I added my field
<tr>        <td scope="col"><span sugar='slot14'>{$MOD.LBL_START_TIME}:</span sugar='slot'></td>        <td><span sugar='slot14b'><input id='start_time' name='wiz_step1_start_time_c' title='{$MOD.LBL_START_TIME}' type="text" value="{$START_TIME_C}" ></span sugar='slot'></td>        </tr>

And after that added validation for my field

addToValidate('wizform', 'start_time', 'time', false,  document.getElementById('start_time').title);

So now it works okay. Although I haven't figured out how to add validations when I click on the edit button and then click on save. Can someone please provide some guidance?

Kind Regards,
Madhav Shenoy