We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 27519
    • 275 Posts
    I have a form with the following field:

    <div style='width: 100%'>
      <input type='text' class='field' size='40' name='email:email' id='email' value='[[+fi.email]]' />*
     </div>
    


    The form is processed with a Formit call:
    [[!FormIt?  
       &hooks=`SaveBooking2Db,spam,email,redirect`  
       &emailTpl=`[[+emailTpl]]`  
       &emailTo=`[email protected]`  
       &redirectTo=`1`
    ]]
    


    The SaveBookind2Db snippet in the hooks is a custom hook that tries to save the values of the form fields to a database using a PHP helper class. The snippet instantiates the helper class and sets its properties with the values entered into the form. For the above field it does:

    $dbHelper->email = $modx->getPlaceholder("email");
    


    Unfortunately, this doesn’t seem to work as the properties of $dbHelper remain empty.

    I’m a stumped to be honest, as the email chunk that follows the SaveBooking2Db snippet relies on the same information and it gets the job done.

    I must be doing something wrong, only what???
      MODx Revolution / MAMP / OS X
      • 4172
      • 5,888 Posts
        -------------------------------

        you can buy me a beer, if you like MIGX

        http://webcmsolutions.de/migx.html

        Thanks!
        • 27519
        • 275 Posts
        Excellent! That worked. Thanks very much for your reply. I was breaking my head on this one for a while now....


        That leaves me to conclude that my approach was wrong.

        Why are Formit placeholders not approachable via the getPlaceholder() method??

        They are in fact placeholders, are they not????...
          MODx Revolution / MAMP / OS X
        • Some snippets maintain their own placeholder processing; instead of loading their placeholders into the MODx placeholders array they use something like the PHP str_replace() function to replace placeholders in their tpls with the values. I can’t say for sure that this is how Formit works, but many snippets do.
            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
            • 27519
            • 275 Posts
            Quote from: sottwell at Sep 13, 2010, 06:23 AM

            Some snippets maintain their own placeholder processing; instead of loading their placeholders into the MODx placeholders array they use something like the PHP str_replace() function to replace placeholders in their tpls with the values.

            I see. What would be the main consideration for not using the MODx placeholders array?
              MODx Revolution / MAMP / OS X
            • The chunk (or file) tpls are retrieved unprocessed from the database (or file system) by the snippet, so no MODx parsing is done on it at all. Especially if the snippet has the option of using a file or a chunk, the MODx parser can’t be involved. The snippet has to get the placeholders and placeholder values merged. This has to be done for each item the snippet is applying the tpl to (for example, with Ditto it’s each resource in the parent container), so it makes sense to handle it within the snippet’s code loop. This could be done using MODx API functions (at least in Evo, not sure if Revo has the corresponding API functions) toPlaceholders() and mergePlaceholderContent(), but since these aren’t well-document and since placeholders in chunk tpls are 99.9% of the time only relevant within the loop iteration of the snippet it’s probably easier to just use str_replace(). Again, this is Evo; Revo may have a better way of handling tpls and placeholders. In any case, it’s totally up to the third-party developer writing the snippet.
                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