We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 36467
    • 73 Posts
    I want to post "uid" value to next page via POST only and want to set hidden field which will contain "uid" as a value. I believe practically its not allowed to pass values to chunk. I want to know whats the proper way so i can get POST data and use that value in chunk ??

    My procedure

    1) I have created resource (document) which contains call to snippet and then chunk

    2) snippet contains value retrieved from POST

    3) chunk contains a form and fields, I want to inject that POST value in this form.
    [ed. note: amitpatil last edited this post 14 years, 1 month ago.]
      • 3749
      • 24,544 Posts
      Are you getting the chunk in the snippet with $modx->getChunk (or could you)?

      If so, you can put placeholder tags in the chunk and send them along in the getChunk() tag like this:

      $fields = array(
          'placeholdelterNameOne' => $_POST['something'],
          'placeholdelterNameTwo' => $_POST['something_else'],
      )
      
      $chunk = $modx->getChunk('ChunkName', $fields);
      



      ------------------------------------------------------------------------------------------
      PLEASE, PLEASE specify the version of MODX you are using.
      MODX info for everyone: http://bobsguides.com/modx.html
        Did I help you? Buy me a beer
        Get my Book: MODX:The Official Guide
        MODX info for everyone: http://bobsguides.com/modx.html
        My MODX Extras
        Bob's Guides is now hosted at A2 MODX Hosting
        • 36467
        • 73 Posts
        Thanks Bob, Thanks for the solution I will try this and will let you know how it goes
          • 36467
          • 73 Posts
          I found another similar solution that i used, concept is almost same just little change

          snippet:
          $placeholders = array();
          $placeholders['uid'] = $_POST['uid'];
          $modx->setPlaceholders($placeholders);
          

          chunk
          <input type="hidden" name="uid" value="[[!+uid]]" />
            • 3749
            • 24,544 Posts
            Yes, that will work as well. Using getChunk() is a little less sensitive to the parsing order and less prone to conflicts, but your method usually works fine.

            BTW, if you only have one, you can just use this:

            $modx->setPlaceholder('uid', $_POST['uid']);



            If the snippet is called uncached (and I think it should be), you shouldn't need to have the placeholder tag uncached.


            ------------------------------------------------------------------------------------------
            PLEASE, PLEASE specify the version of MODX you are using.
            MODX info for everyone: http://bobsguides.com/modx.html
              Did I help you? Buy me a beer
              Get my Book: MODX:The Official Guide
              MODX info for everyone: http://bobsguides.com/modx.html
              My MODX Extras
              Bob's Guides is now hosted at A2 MODX Hosting
              • 36467
              • 73 Posts
              Ahaaa thanks for this quick shortcut