We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 42161
    • 42 Posts
    I am getting a variable as $_GET['flat_id'] on the page and I want its value to ba available for a custom FormIt hook.

    On the page FormIt is called as:
    [[!FormItRetriever]]
    [[!FormIt? 
    	&hooks=`testCRUD`
    	&successMessage=`Done.`
    	&newFlatID=`[[!testHook]]`
    ]]
    [[!setNewObjPlaceholders]]
    

    Where testHook simply returns the $_GET value:
    <?php
    return $_GET['flat_id'];
    

    And [[!setNewObjPlaceholders]] does nothing is the form has been submitted (so it got a value of a hidden <input>) or sets the [[fi.*]] placeholders if the page is loaded for the first time.
    I'm tryibg to get the value of newFlatID in the hook as follows:
    $newFlatID = $modx->getPlaceholder('newFlatID');

    but $newFlatID seems to be empty.
    Can anybody help?

    MODX ver. 2.2.6
    FormIt ver 2.2.0 [ed. note: localhot last edited this post 10 years, 10 months ago.]
    • I don't think you can get the placeholder like that... sounds like maybe you're crossing wires. You'd have to set the placeholder before you can get it.

      FYI, you should filter your value -- if it's an integer, force it so it's safe:

      return (int) $_GET['flat_id'];
        • 3749
        • 24,544 Posts
        If I'm understanding you, I think you might need to use this:

        $hook->getValue('flat_id');
          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
        • Normally in a script you would use the $scriptProperties['someValue']. But form it provides the $hook->getValue as Bob pointed out.
            Get your copy of MODX Revolution Building the Web Your Way http://www.sanitypress.com/books/modx-revolution-building-the-web-your-way.html

            Check out my MODX || xPDO resources here: http://www.shawnwilkerson.com
            • 42161
            • 42 Posts
            Quote from: BobRay at Jun 03, 2013, 11:13 PM
            If I'm understanding you, I think you might need to use this:

            $hook->getValue('flat_id');

            Maybe you meant
            $hook->getValue('newFlatID');

            Because I'm not sure that $_GET is available to FormIt hooks?

            P.S. I solved my problem with a $_SESSION variable.

            Thank you for help anyway!