We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 53073
    • 10 Posts
    I have a problem to pass &where option to Formit with a variable.

    The following code works fine to update record with id=12
    
    [[!FormIt?
        &hooks=`spam,FormIt2db,email`
        &preHooks=`db2FormIt`
        &fieldname=`updt`
        &where=`{"id":"12"}`
        &packagename=`modx_ctm_passtmag_formit2db`
        &tablename=`ctm_passtmag`
        &emailTpl=`emailFormitTestTpl`
        &emailTo=`[email protected]`
        &validate=`nospam:blank`
        &autoPackage=`1`
    ]]
    


    All is Ok, record is updated

    But this one doesn't work :
    [[!FormIt?
        &hooks=`spam,FormIt2db,email`
        &preHooks=`db2FormIt`
        &fieldname=`updt`
        &where=`{"id":"[[getUrlParam? &name=`updt`]]"}`
        &packagename=`modx_ctm_passtmag_formit2db`
        &tablename=`ctm_passtmag`
        &emailTpl=`emailFormitTestTpl`
        &emailTo=`[email protected]`
        &validate=`nospam:blank`
        &autoPackage=`1`
    ]]
    

    No update, a new record is created !

    Any idea?
      • 38783
      • 571 Posts
      Does this work?

      &where=`{"id:=":"[[!getUrlParam? &name=`updt`]]"}`


      You may need to specify whether the parameter is an integer or a string with &string=`1` or &int=`1`
        If I help you out on these forums I would be very grateful if you would consider rating me on Trustpilot: https://uk.trustpilot.com/review/andytough.com

        email: [email protected] | website: https://andytough.com