We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 31037
    • 358 Posts
    Steve, I’m way ahead of you, speed up man! Just kidding! tongue

    When you say "insert the contents of any variable into a placeholder" I guess that you mean a placeholder that you can use in an eForm? If so, you can do it this way:

    Create a snippet that you call "uncle68". If you want to use another name thats ok wink

    In that snippet you create a function like this:

    function uncle68_4ever(&$fields) {
    }

    Whithin the {} you define your placeholder by doing like this: $fields[nameofplaceholder] = ’content of placeholder’;

    Content of placeholder can be what ever you want, like your own varible:

    $myVarible = ’Hi! My name is Steve’;
    $fields[’nameofplaceholder’] = $myVarible;

    You can actually even do like this to have dynamic forms:

    $myVarible = ’<input type="text" name="email" size="40" maxlength="40" eform="Your Email Address:email:1" /> ’;
    $fields[’nameofplaceholder’] = $myVarible;

    The problem with that is that validation does not work! But if you only are going to use it for hidden fields that would be no problem!

    In the document from which you call eForm, you should add a call to the snippet you made *before* the call to eForm. And also add this to the eForm call: &eFormOnBeforeFormMerge=`nameOfYourFunction`

    The complete snippet you made should look something like this:

    function uncle68_4ever(&$fields) {
    $myVarible = ’Hi! My name is Steve’;
    $fields[’nameofplaceholder’] = $myVarible;
    //more placeholders //
    return true;
    }
    return ’’;

    As I said, this may not be what you asked for, and I hope you don’t think my instructions asumes that you didn’t already know this smiley

    Good luck

    /Anders

    EDIT: As I understand it might be better to use the eFormOnBeforeFormParse for creating form elements dynamically, but I just can’t get that event to work. The function I’ve created seems not to be called. I’ll test some more... does it work for anyone else?
      • 30223
      • 1,010 Posts
      You can actually even do like this to have dynamic forms:

      $myVarible = ’<input type="text" name="email" size="40" maxlength="40" eform="Your Email Address:email:1" /> ’;
      $fields[’nameofplaceholder’] = $myVarible;

      The problem with that is that validation does not work! But if you only are going to use it for hidden fields that would be no problem!

      In the document from which you call eForm, you should add a call to the snippet you made *before* the call to eForm. And also add this to the eForm call: &eFormOnBeforeFormMerge=`nameOfYourFunction`

      Just for clarity’s sake... Use the eFormOnBeforeParse event if you want to dynamically add form elements to a form. That way they will be parsed and more importantly become part of the form validation when posted.