We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 36926
    • 701 Posts
    According to the docs you can set a value within a custom hook that can then be read within the email chunk:
    https://rtfm.modx.com/extras/revo/formit/formit.tutorials-and-examples/formit.examples.custom-hook

    Setting Values
    One common thing for custom hooks to do is to calculate new field values – this emulates having a hidden field on the form. For example, your customhook Snippet can set a datestamp for when the form was submitted.

    But I can only get to work if I have a hidden input field with the same name within the form. In fact if I don't have the hidden value then the email doesn't seem to send, although the form seems to submit. Anyone have the same issue?

    I've simplified the hook to make sure it's not the hooks code
    $hook->setValue('test', 'testvalue');
    return true;
    


    Also just noticed that if I have field called name, then if you try and set this in the hook it also fails to email unless it has a value.

      • 4172
      • 5,888 Posts
      can you show us the whole thing.
      The form and the Formit-call?
        -------------------------------

        you can buy me a beer, if you like MIGX

        http://webcmsolutions.de/migx.html

        Thanks!
        • 28042 ☆ A M B ☆
        • 24,524 Posts
        All setValue is doing is setting the value of a given existing field. There doesn't appear to be an API function for creating new fields. You'll need to access the fields array directly:
        $hook->fields[$key] = $value;
          Studying MODX in the desert - http://sottwell.com
          Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
          Join the Slack Community - http://modx.org
          • 36926
          • 701 Posts
          Thanks both for the replies. I've actually managed to get it working. Not 100% what it was as I made a few changes. But the form and call were in a chunk that was being pulled in via a contentBlocks chunk fields.

          I've changed this and placed the chunk directly into the resource which seems to work and some times not. I'm now calling that chunk unchached which so far seems to being working as expected.

          Thanks again.