We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 10313
    • 375 Posts
    Hello,

    I have a problem, but I don’t know, "where" it is. This is the situation:

    Evolution 1.0.2, eform 1.4.4.6, PHx 2.1.3.

    I have an "order" form. This form is partially pre-filled with values that are fetched according to the page where I click the "order" button. I do this with a small snippet I have written. The snippet is called just before generating the form with eform. The ID of the calling document is passed by a GET parameter "m". In that snippet, I set two placeholders, these placeholders are used in my form template (chunk).

    Now the problem is: In the form, I only get the value of one of these two placeholders. The other placeholder is empty.

    Here is my snippet:
    <?php
    $maschine = 0+ $_GET['m'];
    if($maschine > 0){
      $docfield = $modx->getTemplateVarOutput(array('pagetitle','bild'), $maschine, 1);
      $titel = $docfield['pagetitle'];
      $bild = $docfield['bild'];
      if($bild != ""){
        $bild = "<img src='" . $bild . "' alt='' width='198'>";
      }
      else{
        $bild = "kein Bild";
      }
    }
    else{
      $titel= "Bitte eintragen";
      $bild = "";
    }
    
    $modx->setPlaceholder('mietBild',$bild);
    $modx->setPlaceholder('mietName',$titel);
    ?>
    


    In my form, I can only output [+mietName+], but not [+mietBild+]. I have already tried anything, I think:

    • changed the order of the setPlaceholder statements: no change in behaviour
    • changed the name of [+mietBild+] to many other names: no change in behaviour
    • deleted the setting of the working [+mietName+], so that only the faulty PH is used: no output, either
    • assigned the value $bild to [+mietName+]: the correct IMG tag is output, so it is not a question of retreiving or passing the values
    • deactivated the PHx plugin (although I need it), because I found hints that this might cause the problem: no change
    • calling the snippet both cached and uncached: no change (the pages are not cached, either)

    What can it be and what can I still try? I am quite out of ideas.

    Thanks for any ideas
    Martin
      • 26931
      • 2,314 Posts
      Hi FuryDE,

      i did something similar, have a look at this post: http://modxcms.com/forums/index.php/topic,47130.msg277289.html#msg277289
        • 28042 ☆ A M B ☆
        • 24,524 Posts
        Actually it would be much better to use eForm’s &eFormOnBeforeFormMerge event parameter, and modify its available &$fields array in your snippet to plug in your fields.

        http://wiki.modxcms.com/index.php/Populate_eform_with_dynamic_data
          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
          • 10313
          • 375 Posts
          Thank you both, sharkbit and Susan!

          Like sharkbit, I have used [tt]&eFormOnBeforeFormParse[/tt] because one of the data was put into a field but the other (the image) will be placed next to the input fields.

          Many thanks
          Martin