We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 37580
    • 17 Posts
    graham.buckley Reply #1, 12 years ago
    Can anyone help with regards to an issue I'm having with the display of the email that FormIt sends whenever a form is submitted. I'm currently using the latest version of Modx Revo and most up to date version of FormIt.

    The problem I have is whilst the rest of the email brings through the fields which have been submitted I seem to have an issue with the checkbox ones whereby if it is ticked it'll displayed the value ie "Y" in this case yet if not it'll display the placeholder name ie [[+service1]]. What I ideally wanted to do with this area was to not display information if a service option wasn't ticked and have tried to do this using output modifiers (which coincidentally also end up being displayed in the email as well). An example would be:-

    [[+service1:is=`Y`:then=`Service: [[+service1]] (qty: [[+service1qty]]) (size: [[+service1size]])

    `]]

    which does work when I output it to the Thank You page. I just kind of expected it to work in the same way yet it clearly doesn't. I just wondered if anyone else has encounted this issue and whether they know the answer to resolve it.

      • 13643
      • 44 Posts
      Offhand, it sounds to me like your "is" output filter isn't working in the context of your email template. Do you have filters on any other fields in the same template, and are they working?
        • 16348
        • 64 Posts
        FormIt doesn't parse the email template in the same way as modx does for ordinary chunks or resources. It only handles clean placeholders.
        The easiest way to handle your problem when the checkbox isn't checked is to add an empty hidden input field before your checkbox, see http://rtfm.modx.com/display/ADDON/FormIt.Handling+Selects%2C+Checkboxes+and+Radios.

        If you wan't to style the output in your email a custom hook can be a solution.
        <?php
        $service1 = $hook->getValue('service1');
        if(empty($service1)) {
          $output = '';
        } else {
         $output = 'Service: (qty: ) (size: )';
        }
        $hook->setValue('service2',$output);
        return true;
        
          • 37580
          • 17 Posts
          graham.buckley Reply #4, 12 years ago
          Thanks guys for getting in touch. I don't use any other filters within any other fields yet when I have I recall they haven't worked either. That sounds like a great solution about using a hook instead. I shall give that a go and let you know how I get on. Cheers again.
            • 37580
            • 17 Posts
            graham.buckley Reply #5, 12 years ago
            Many thanks for the advice Kristoffer, with the above code I've got it all working perfectly. So instead of having within the email:-

            [[+service1:is=`Y`:then=`[[+service1]]: (qty:[[+service1qty]] ) (size:[[+service1size]] )`]]


            I just have:-

            [[+service1]]


            Whereby after adapting the above code to what I need and creating the following snippet ie:-

            <?php
            $service1 = $hook->getValue('service1');
            $service1qty = $hook->getValue('service1qty');
            $service1size = $hook->getValue('service1size');
            if(empty($service1)) {
            	$output1 = '';
            } else {
            	$output1 = '<strong>Service:</strong> (<strong>Qty:</strong> '.$service1qty.') (<strong>Size:</strong> '.$service1size.')
            ';
            }
            $hook->setValue('service1',$output1);
            return true;


            I then just had to reference the hook I created in the FormIt code. Awesome!