We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 18913
    • 654 Posts
    I am using eForm to add, update and delete some database records. In each case, there is a function that is called once the form is submitted which performs the relevant SQL operation.

    In order to correctly update and delete, I need to take the record key and then use that in the post-submit function that gets called, but I don’t want this to be visible to the user or to take up any real estate in the form.

    If it is stored in a hidden field, then the form processing gets derailed. I can put it in a readonly field but that takes up space.

    I’m probably missing something very obvious, but if anyone can point me to a solution, I’d be appreciative. FWIW, here’s an example of the eform call for the update function:
    [!data_parsing_functions!]
    [!eForm? &noemail=`true` &protectSubmit=`0` &tpl=`eformdata_chunk` &formid=`DataForm` &eFormOnBeforeFormParse=`populateDataForm` &eFormOnBeforeMailSent=`updateDatabaseEntry` &thankyou=`success_chunk` &allowhtml=`0`!]


    And here’s what the currently-offending section of form code looks like :
    		<input type="text" name="internalKey"  value="[+internalKey+]" readonly="true"/><br />
    		<label for="coName">Member Name:*
    		<input name="fullname" id="coName" type="text" value="[+fullname+]" size="30"  eform="Member Name::1:"/>


    "internalKey" is what gets pulled from the database by the function "populateDataForm". I’d like to have it available to the "updateDatabaseEntry" function without it being carried through the form or visible.

    Any thoughts would be appreciated. And apologies in advance if the solution should be easy to find or obvious - I just happen to be too far down a rabbit hole at the moment!

    MattC
      • 28042 ☆ A M B ☆
      • 24,524 Posts
      If you use a hidden field with eform="::0::" then it won’t bother the eForm processing.

      http://wiki.modxcms.com/index.php/EForm#Hidden_fields
        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
        • 18913
        • 654 Posts
        Ah. Missed that. Thanks for the pointer - I’ll see what I can do with it.
        MattC