<![CDATA[ Custom email in Formit - My Forums]]> https://forums.modx.com/thread/?thread=104356 <![CDATA[Custom email in Formit]]> https://forums.modx.com/thread/104356/custom-email-in-formit?page=4#dis-post-561313
The default email only has '[[+fields]]' and that sort of dumps everything out. How to have finer control?]]>
nuan88 Sep 01, 2018, 09:12 PM https://forums.modx.com/thread/104356/custom-email-in-formit?page=4#dis-post-561313
<![CDATA[Re: Custom email in Formit]]> https://forums.modx.com/thread/104356/custom-email-in-formit?page=4#dis-post-562180 marielvdoever Oct 18, 2018, 11:32 AM https://forums.modx.com/thread/104356/custom-email-in-formit?page=4#dis-post-562180 <![CDATA[Re: Custom email in Formit]]> https://forums.modx.com/thread/104356/custom-email-in-formit?page=4#dis-post-561699
Here is the code he provided before. Its a custom hook that will go in the call along with the email tpl

The problem is that the field names are dynamic so this is why I advised to setup the names with 'product_', so in a hook you can find any values with this prefix, explode them and then dictate their return - someone may be able to advise you on the correct php for this as I assume mine didnt work wink

Try this - it may not work but if it fails check the error log for guidance or keep tweaking it to get it work smiley I think each time it loops through the value may be replaced though so I think you need to use str replace... hopefully someone can guide you on that.

<?php
  
$allValues = $hook->getValues();
$product = array();
 
foreach($allValues as $key => $value) {
    if (strpos($key, 'products_') !== false) {
  
        $modx->log(xPDO::LOG_LEVEL_ERROR, 'There were values found with the prefix product_');
  
        list($prefix, $productTitle) = explode('_', $key);
  
        $modx->log(xPDO::LOG_LEVEL_ERROR,'The products found were:' . $productTitle);
  
        $productList .= 'Title:' . $product[$key] . 'Quantity' . $product[$value];
  
        $hook->setValue('products', $productList);
  
        return true;
  
    } else{
  
        $modx->log(xPDO::LOG_LEVEL_ERROR, 'There were no values matching product_');
  
        return false;
  
    }
}
]]>
nuan88 Sep 22, 2018, 01:41 PM https://forums.modx.com/thread/104356/custom-email-in-formit?page=4#dis-post-561699
<![CDATA[Re: Custom email in Formit]]> https://forums.modx.com/thread/104356/custom-email-in-formit?page=4#dis-post-561696 ]]> lkfranklin Sep 22, 2018, 07:48 AM https://forums.modx.com/thread/104356/custom-email-in-formit?page=4#dis-post-561696 <![CDATA[Re: Custom email in Formit]]> https://forums.modx.com/thread/104356/custom-email-in-formit?page=4#dis-post-561693 Quote from: marielvdoever at Sep 20, 2018, 10:43 PM
Doesn't seem to work for me.
It is like it don't know the difference between 0 and a value higher then zero.
Would still appreciate it a lot if someone has a solution for me!

I really wish I knew. I think the goal is to default in the form to a null response, no 0 but just nothing. Then it should be gone...

in this case maybe each element does have data because its got name of the item

I am really stumped]]>
nuan88 Sep 21, 2018, 09:11 PM https://forums.modx.com/thread/104356/custom-email-in-formit?page=4#dis-post-561693
<![CDATA[Re: Custom email in Formit]]> https://forums.modx.com/thread/104356/custom-email-in-formit?page=3#dis-post-561681 It is like it don't know the difference between 0 and a value higher then zero.
Would still appreciate it a lot if someone has a solution for me!]]>
marielvdoever Sep 20, 2018, 10:43 PM https://forums.modx.com/thread/104356/custom-email-in-formit?page=3#dis-post-561681
<![CDATA[Re: Custom email in Formit]]> https://forums.modx.com/thread/104356/custom-email-in-formit?page=3#dis-post-561573
Here is the list of output modifiers, they should work in this case

https://docs.modx.com/revolution/2.x/making-sites-with-modx/customizing-content/input-and-output-filters-(output-modifiers)

Here are some likely suspects:

Equal to
[[+numbooks:isequalto=``:then=``:else=`output`]]

Not equal to

[[+numbooks:notequalto=``:then=`output`:else=``]]]]>
nuan88 Sep 17, 2018, 12:20 PM https://forums.modx.com/thread/104356/custom-email-in-formit?page=3#dis-post-561573
<![CDATA[Re: Custom email in Formit]]> https://forums.modx.com/thread/104356/custom-email-in-formit?page=3#dis-post-561569 Quote from: nuan88 at Sep 16, 2018, 06:31 PM
Would this work

<select name="Value[[+title:default='']]">

</select>

It doesn't change anything, unfortunately.
]]>
marielvdoever Sep 16, 2018, 11:30 PM https://forums.modx.com/thread/104356/custom-email-in-formit?page=3#dis-post-561569
<![CDATA[Re: Custom email in Formit]]> https://forums.modx.com/thread/104356/custom-email-in-formit?page=3#dis-post-561566
<select name="Value[[+title:default='']]">

]]>
nuan88 Sep 16, 2018, 06:31 PM https://forums.modx.com/thread/104356/custom-email-in-formit?page=3#dis-post-561566
<![CDATA[Re: Custom email in Formit]]> https://forums.modx.com/thread/104356/custom-email-in-formit?page=3#dis-post-561565 Just tried the code, it still shows the full list.]]> marielvdoever Sep 16, 2018, 06:00 PM https://forums.modx.com/thread/104356/custom-email-in-formit?page=3#dis-post-561565