Home › Forums › Quform WordPress › Remove empty fields from customize email content.
- This topic has 18 replies, 3 voices, and was last updated 11 years, 2 months ago by
Ally.
- AuthorPosts
- December 8, 2013 at 8:11 am #7765
yanivmirel
ParticipantHi,
Is there a way to hide/remove empty fields within the customize email content.
When I am creating the html content I am inserting all fields variables because I can’t tell which one the client will fill up.
But I really need to hide the empty ones from my email (I have more than 100 inputs)Thanks.
December 8, 2013 at 3:11 pm #7771Ally
Support StaffYou don't have permission to view this content. Please log in or register and then verify your purchases to gain access.
December 9, 2013 at 4:31 pm #7785yanivmirel
ParticipantAnd I do I add the entry ID to that html/php?
Is this the correct way to add date and time separate.
Date: <?php echo date(‘d/m/Y’); ?>, Time: <?php echo date(‘H:i’); ?>Thanks for great support
December 9, 2013 at 4:36 pm #7786yanivmirel
ParticipantMy HTML will be a huge table.
Do I need to wrap the code above in <?php …… ?>
Can you give an example of how to wrap the if statement.
Here is a section of my HTML.<table dir=”rtl” border=”1″ align=”center” style=”width: 600px;margin:0 auto;”>
<tbody>
<tr>
<th colspan=”2″ style=”text-align: right;”>Client info</th>
</tr>
<tr>
<td>Name</td>
<td><?php echo $form->getValueHtml(‘iphorm_1_1’); ?></td>
</tr>
<tr>
<td>Did you work with us before</td>
<td><?php echo $form->getValueHtml(‘iphorm_1_120’); ?></td>
</tr>Thanks
December 10, 2013 at 5:00 pm #7803Ally
Support StaffYou don't have permission to view this content. Please log in or register and then verify your purchases to gain access.
December 11, 2013 at 6:40 am #7822yanivmirel
ParticipantHi,
Once I am done with that, do I need to set something in the admin.
like Unchecking “Customize email content” or something…..?Will the plugin know to submit it from the new function instead?
December 11, 2013 at 6:43 am #7823yanivmirel
ParticipantCan you also reply to my other question #7785 ?
December 11, 2013 at 7:18 am #7824yanivmirel
ParticipantOne last question.
The same if statement (->isEmpty()) is good to check Boolean field?December 11, 2013 at 9:39 am #7833Ally
Support StaffYou don't have permission to view this content. Please log in or register and then verify your purchases to gain access.
December 11, 2013 at 9:52 am #7836Ally
Support StaffYou don't have permission to view this content. Please log in or register and then verify your purchases to gain access.
December 28, 2013 at 8:07 pm #7985yanivmirel
ParticipantHi,
I have a field with a radio select, how to I check for the value with the if statement.
something like: <?php if (!$form->getElement(‘iphorm_1_120’) == ‘yes’) : ?>
when ‘yes’ is the value.is this the correct way?
December 29, 2013 at 4:54 pm #7988josef777
ParticipantYaniv
Do the following because you are doing it the hard way :
see the following guides
1-open autoreply-content.php and Modify iphorm_1_2 and iphorm_1_1 to the ids from your form (those are Title and Name in my form ) and edit the text at the top to whatever you wish , do not do anything to the rest of the code (it’s from email-html.php, just changed the style).
2- Follow the guides above for the functions.php
Now go and test it !
autoreply-content.php
Dear <?php echo $form->getValueHtml('iphorm_1_2'); ?> <?php echo $form->getValueHtml('iphorm_1_1'); ?><br /><br />
below is your submission to your company , thank you in advance and we will get in touch with you shortly .<br /><br />
Best Regards<br />
Your Company<br /><br />Phone : +43 000 000 000<br />
Email : office@yourdomain.com<br />
Website: http://yourdomain.com<br />
--------------------------------------<br /><table width="600" cellpadding="0" cellspacing="0" border="0" style="font: 14px Helvetica, Arial, sans-serif;">
<tr>
<td valign="top" style="font-family: Helvetica, Arial, sans-serif; font-size: 20px; font-weight: bold; color: #282828; padding-bottom: 10px;"><?php echo esc_html($mailer->Subject); ?></td>
</tr>
<tr>
<td valign="top"><table width="100%" border="0" cellpadding="2" cellspacing="0" style="border-collapse:collapse;">
<?php
$elements = $form->getElements();
foreach ($elements as $element) : ?>
<?php if (!$element->isHidden() && (!$element->isEmpty() || ($element->isEmpty() && $form->getNotificationShowEmptyFields()))) : ?>
<?php if ($element instanceof iPhorm_Element_Groupstart) : ?>
<?php if ($element->getShowNameInEmail() && strlen($adminTitle = $element->getAdminTitle())) : ?>
<tr>
<td colspan="2" valign="top" style="border: 1px solid #F0F0F0;font-family: Helvetica, Arial, sans-serif; font-size: 16px; font-weight: bold; color: #282828; padding-top: 15px; padding-bottom: 10px;"><?php echo esc_html($adminTitle); ?></td>
</tr>
<?php endif; ?>
<?php else : ?>
<tr>
<th scope="row" style="font-size: 12px;border: 1px solid #F0F0F0;padding: 10px;text-align: left;vertical-align: top;width: 150px;"><?php echo esc_html($element->getAdminLabel()); ?></th>
<td style="border: 1px solid #F0F0F0;font-size: 12px;line-height: 20px;margin-bottom: 9px;padding: 8px 10px;">
<?php echo $element->getValueHtml(); ?>
</td>
</tr>
<?php endif; ?>
<?php endif; ?>
<?php endforeach; ?>
</table></td>
</tr>
</table>
email-content.php
<?php if (!defined('IPHORM_VERSION')) exit; ?><html>
<body leftmargin="0" marginwidth="0" topmargin="0" marginheight="0">
<table width="600" cellpadding="0" cellspacing="0" border="0" style="font: 14px Helvetica, Arial, sans-serif;">
<tr>
<td valign="top" style="font-family: Helvetica, Arial, sans-serif; font-size: 20px; font-weight: bold; color: #282828; padding-bottom: 10px;"><?php echo esc_html($mailer->Subject); ?></td>
</tr>
<tr>
<td valign="top"><table width="100%" border="0" cellpadding="2" cellspacing="0" style="border-collapse:collapse;">
<?php
$elements = $form->getElements();
foreach ($elements as $element) : ?>
<?php if (!$element->isHidden() && (!$element->isEmpty() || ($element->isEmpty() && $form->getNotificationShowEmptyFields()))) : ?>
<?php if ($element instanceof iPhorm_Element_Groupstart) : ?>
<?php if ($element->getShowNameInEmail() && strlen($adminTitle = $element->getAdminTitle())) : ?>
<tr>
<td colspan="2" valign="top" style="border: 1px solid #F0F0F0;font-family: Helvetica, Arial, sans-serif; font-size: 16px; font-weight: bold; color: #282828; padding-top: 15px; padding-bottom: 10px;"><?php echo esc_html($adminTitle); ?></td>
</tr>
<?php endif; ?>
<?php else : ?>
<tr>
<th scope="row" style="font-size: 12px;border: 1px solid #F0F0F0;padding: 10px;text-align: left;vertical-align: top;width: 150px;"><?php echo esc_html($element->getAdminLabel()); ?></th>
<td style="border: 1px solid #F0F0F0;font-size: 12px;line-height: 20px;margin-bottom: 9px;padding: 8px 10px;">
<?php echo $element->getValueHtml(); ?>
</td>
</tr>
<?php endif; ?>
<?php endif; ?>
<?php endforeach; ?>
</table></td>
</tr>
</table>
</body>
</html>
- This reply was modified 11 years, 2 months ago by
josef777.
December 29, 2013 at 10:52 pm #7992yanivmirel
ParticipantHi Josef,
Thank you for your answer but it’s not that simple with my form.
My form has 11 different sections with total of 150 elements when 45 of them are based on conditional fields.
My email content is organized with table headers for each section and so on and so on….
I already finish with the hard job (I guess I did it the hard/long way).
I just need to not include few elements based on other elements radio choices.I will appreciate if you can answer my last question (#7985)
Thanks
December 29, 2013 at 11:43 pm #7993josef777
Participant1- it’s up to you but it doesn’t matter how many sections or fields you have or whether they have conditional logic or not , the above files will hide empty fields and email what been selected .
2- (#7985) You have to wait for Ally , my php is very limited 🙂
December 31, 2013 at 4:50 am #8025yanivmirel
ParticipantAny news from the support staff?
- This reply was modified 11 years, 2 months ago by
- AuthorPosts
- You must be logged in to reply to this topic.