The following warnings occurred: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Warning [2] Undefined array key "avatartype" - Line: 783 - File: global.php PHP 8.1.31 (Linux)
|
How to create a customized email template that omits empty fields? - Printable Version +- Form Tools (https://forums.formtools.org) +-- Forum: Form Tools (https://forums.formtools.org/forumdisplay.php?fid=1) +--- Forum: General Discussion (https://forums.formtools.org/forumdisplay.php?fid=5) +--- Thread: How to create a customized email template that omits empty fields? (/showthread.php?tid=4902) |
How to create a customized email template that omits empty fields? - Francois - Dec 16th, 2014 Hi, I’m creating a timesheet form that will have over 180 fields in it, of which only about a 1/3 of the fields will be filled in per submission at any one time, whilst another person would use a different 1/3 depending on the days and projects worked on. I need to create an email template that will generate an email, which only has those fields filled in, to be part of the email, so I don’t want the other 2/3’s of the field labels in the email that are empty. The built in FT template "To User - Omit Empty Fields" does the job but . . . I need to create a custom layout that represents the form data in a more logical and consistent manner rather than a 2 column list. So what I’m wanting is the code that checks for which fields have been filled in and then that data to populate the email. As an example consider the simple template below: Hi {$ANSWER_Contractor_First_Name}, This time sheet has been submitted by {$ANSWER_Contractor_First_Name} {$ANSWER_Contractor_Last_Name}. You worked on the following days: {$QUESTION_Work_Mon} {$ANSWER_Work_Mon} {$QUESTION_Work_Tue} {$ANSWER_Work_Tue} {$QUESTION_Work_Wed} {$ANSWER_Work_Wed} {$QUESTION_Work_Thu} {$ANSWER_Work_Thu} {$QUESTION_Work_Fri} {$ANSWER_Work_Fri} {$QUESTION_Work_Sat} {$ANSWER_Work_Sat} {$QUESTION_Work_Sun} {$ANSWER_Work_Sun} You worked a total of {$ANSWER_Total_Hrs} Hours So in the above example the work days are check boxes, which output “Yes” if ticked so if the contractor only worked Monday and Thursday I don’t want the “Field Label” displayed for the days not worked. Without such a mechanism to limit what is displayed it would make for a very long and messy email if it contained all the necessary fields that could be filled in – for the real email template it will contain over 180 fields 2/3’s of which would be empty depending on the work carried out by any given contractor. I hope this explains my problem and that a kind soul out there can either help or point me in the right direction so as I can try to work it out myself. Francois |