We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 29626
    • 34 Posts
    Hi, I have tried to set dynamically a field before making a programmatic call of eform snippet.
    That’s globally the following try:
    
    /*
    I get some datas from the database properly 
    and I store the [b]to[/b] email adress that I need to use with eForm parameter
    */
    $mail = $myRecordsetData['mailAdress'];
    
    
    $params = array();
    $params['formid'] = 'myFormId';
    $params['tpl'] = 'myFormTemplate';
    $params['report'] = 'myFormReportTemplate';
    //...
    $params['to'] = $mail;
    
    //...
    
    // Execute and print the snippet html form output on screen
    echo $modx->runSnippet('eForm', $params);
    


    The problem is only on the variable!
    $mail


    I don’t know why but eform seems to ignore it completely and send an email to the default admin email adress.
    It works only if I set a string like this when I am setting the email parameter:
    $params['to'] = '[email protected]';


    If anyone could give a workaround, it would be appreciable.
    Cheers.


    Terry.
      • 22303 MODX Staff
      • 10,725 Posts
      Are you sure that shouldn’t be
      <?php
      $mail = $myRecordsetData['mailAddress'];
      ?>
      with two d’s?
        • 29626
        • 34 Posts
        I saw this post.

        But it doesn’t resolve anything.
        I use a variable to display something not static, dynamically retrieved from database...


        >> EDIT
        Thanks OpenGeek, but the naming convention I used to expose my problem upstairs is not the real one.
        The variables names were all verified, and no conflict was raised at my mind.


        >> EDIT 2
        Thanks to the MODx Wiki I have found these documentation:
        Contact Us page:
        
            * [[ContactForm? &sendTo=`[(emailsender)]`]]
            * [!eForm? &formid=`ContactForm` &subject=`[+subject+]` &to=`[(email_sender)]` &ccsender=`1` &tpl=`ContactForm` &report=`ContactFormReport` &gotoid=`46` !] 
        


        So I will use a snippet call to get my email adress and another one for eForm with a placeholder to fix the ’to’ field.

        It is the way I’ll do. But if someone resolve the trick for later purposes, I will open my eyes to see everyone lights wink


        Cheers !

        Thierry.
          • 29626
          • 34 Posts
          The workaround used to aim my goal is the following stuff.

          modx chunk containing the 2 snippets call in my modx document.
          [[eForm_traitementDdeDevelApplicationForm]]
          [!eForm?  &formid=`traitementDdeDevelApplicationsForm` &tpl=`traitementDdeDevelApplicationFormTpl` &report=`traitementDdeDevelApplicationReportTpl` &from=`[+from+]` &fromname=`[+fromname+]` &to=`[+email_prospect+]` &cc=`[+from+]` &subject=`[+subject+]` &sendAsHtml=`1` &vericode=`1`!]
          


          Where the first snippet eForm_traitementDdeDevelApplicationForm defines all the placeholders named in the eForm snippet call... Like the following:
              
              $modx->setPlaceholder('email_prospect', $datasDdeDevelLogiciel['emailProspect']);
              $modx->setPlaceholder('from', '[email protected]');
              $modx->setPlaceholder('fromname', $modx->config['site_name']);
              $modx->setPlaceholder('subject', $modx->config['site_name'].' - Réponse à votre demande de développement de logiciels');
          



          Hope these way could be usefull for beginners and for new modx developpers too wink