MODX Community

$modx->runSnippet('Formit') does not execute

Hey all,

I am stumped with this issue. For whatever reason $modx->runSnippet(‘Formit’) will not run.

I have a snippet called test and here in my code

<?php
$modx->runSnippet('FormIt', array(
    'prehooks'=>'loadCustomValues',
    'hooks'=>'email,FormItSaveForm',
    'emailTpl'=>'MyEmailChunk',
    'emailTo'=>'user@example.com',
    'emailSubject'=>'test email',
    'formName' => 'test form',
));

$modx->runSnippet('QuickEmail', array(
    'to'=>'user@example.com',
));

The QuickEmail runs but not the FormIt. My error logs are not showing my anything, I cleared my all my cache, FormIt will in an empty template but not via a snippet.

Any suggestions?

FormIt’s job is to process user input from a submitted form on the screen. Since there’s no form, nothing has been submitted, so I’m not sure it can be used with runSnippet().

It’s possible that if you put the appropriate data into the $_POST array and then called FormIt with runSnippet() FormIt might process that data as a submitted form, though I’m not sure why you would want to do that, since it would be much simpler to just send the email with QuickEmail or call PhpMailer or the equivalent in your code.

If you want user input for FormIt to respond to, you’ll have to create a form to gather that and put it on the page. In that case, you might as well put the FormIt tag on that page.

ahhhh ok…very noob mistake on my end. I will use PhpMailer. Thanks alot Bob.

Just check out https://docs.modx.com/current/en/extending-modx/services/modmail before jumping in with PHP mailer. The ModMail service makes life so much easier