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

    I have written a plugin to set a placeholder:

    // Sets article select
    
    $ArticleSelect = '<li>
    <input name="" type="checkbox" value="[+id+]" /> <a href="[~[+id+]~]">[+title+]</a><br>
    <p>[+summary+]</p>
    <p>[+link+]</p>
    <p>[+author+]</p>
    <p>[+date+]</p>
    </li>';
    
    $modx->setPlaceholder('ArticleSelect', $ArticleSelect);


    I’ve written a chunk for the template for eForm:

    <form method="post" action="[~[*id*]~]" id="MakeNewsletter" name="MakeNewsletter">
    [+ArticleSelect+]
    <input type="submit" value="Make my newsletter!" />
    </form>


    I am calling eForm from a page, with my template (as above):

    [!eForm? &formId=`MakeNewsletter` &tpl=`MakeNewsletter` &report=`PublishedNewsletter` !]


    And I get this result on my page:

    Invalid Form Id number or name.

    Please help? What am I doing wrong?

    Thank you!

    Sarah
      • 30223
      • 1,010 Posts
      Change &formId=`MakeNewsletter` to &formid=`MakeNewsletter`

      Your plugin code may not work either... Placeholders set with $modx->setPlaceholder are most likely populated AFTER eForm has finished parsing your form. The result is that although the form is displayed in the browser eForm will not be able to parse and validate those fields. You’ll need to replace [+ArticleSelect+] yourself in the eFormOnBeforeFormParse event. See the eForm documentation for examples on how to use the eForm events.
        • 26182
        • 164 Posts
        Thanks for that.

        Yes you’re quite right. It’s not rendering on time. I tried to find some info on eform events but was rather unsuccessful. Can you suggest a good place to start looking?

        Thanks again,

        Sarah
          • 26182
          • 164 Posts
          I tried to make a snippet that has the following code:

          <?php
          //create a placeholder to display the articles that have been posted
          	function displayArticles( &$fields ){
          
                     // Sets article select
                      $ArticleSelect = '<li>
                      <input name="" type="checkbox" value="[+id+]" /> <a href="[~[+id+]~]">[+title+]</a><br>
                      <p>[+summary+]</p>
                      <p>[+link+]</p>
                      <p>[+author+]</p>
                      <p>[+date+]</p>
                      </li>';
          
                       $modx->setPlaceholder('ArticleSelect', $ArticleSelect);		
          		
          	}
          ?>


          Then I called the snippet and the eForm snippet in the page:

          [[eFormAddArticles]]
          [!eForm? &formid=`MakeNewsletter` &tpl=`MakeNewsletter` &eFormOnBeforeFormParse=`displayArticles` &report=`PublishedNewsletter` !]


          And it just goes blank?

          Any help would be great undecided
            • 28042 ☆ A M B ☆
            • 24,524 Posts
            I’m pretty sure all those add-on functions MUST have a "return TRUE" at the end in order for eForm to continue processing. Without it, it just quits at that point.
              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
              • 30223
              • 1,010 Posts
              Indeed, you’re just missing the return true in the function.

              Now where is the data for the placeholders coming from? I’m not quite sure what you’re trying to do with this function. As I said the way you have it now it’s not much use to eForm.

              As to your question about eform events, have a look at the documentation in the assets/eform/docs/ folder or try the wiki (link in my signature). There’s also some examples in this forum, perhaps do a search for "eForm events"
                • 26182
                • 164 Posts
                Hi,

                Thanks for your help. Still bashing away.

                I’m trying to list all the blog posts / articles from a folder with a checkbox beside them. I want the user to be able to select the articles they want to be published in a newsletter for the month.

                I want to extend this so they can attach an image that will be associated with the news item.

                I also want to extend it so that only the current month’s worth of articles is shown for selection for publication for the newsletter.

                Am I going about this completely the wrong way? Is there something pre-existing that I could implement without having to hard code all of this?

                Thanks in advance.

                Sarah smiley