We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
  • You’re not supposed to be using the posthook to display it, but to reformat it to a format the database understands.. So the reverse of your prehook.
      Mark Hamstra • Developer spending his days working on Premium Extras and a MODX Site Dashboard with the ability to remotely upgrade MODX and extras to make the MODX world a little better.

      Tweet me @mark_hamstra, check my infrequent blog at markhamstra.com, my slightly more frequent ramblings at MODX.today or see code at Github.
      • 14372
      • 49 Posts
      Question: Do output modifiers affecting the actual value in the DB?

      I’m thinking that maybe I don’t need a posthook if the output modifier didn’t affect the value in the DB. The prehook however works well ... taking the dateformatted datepicker input and converting it to a unix timestamp (which modx uses to store the DOB). I can confirm this because a submit of the DOB value without the prehook results in an error and ok with the prehook. The chosen value is even visible in the backend.

      So ... what you’ve pointed out about the posthook could be true if the output modifier actually modifies DB content ... and in that case makes sense since the prehook runs everytime I hit submit ... could be the reason why the date field goes blank.

      Just a thought.

      Thanks for your help btw smiley Much appreciated.
        • 14372
        • 49 Posts
        I think I fixed it ... but I’m not sure what exactly fixed it so I’ll just post ALL my changes smiley Feel free to decide what was irrelevant.

        So ... first of all. I conclude that output modifiers DON’T modify DB values, they just format ...

        The changes were made to the Snippet calls ...
        [[!UpdateProfile? &submitVar=`login-updprof-btn` ]]
        
        [[!UpdateProfile? 
             &preHooks=`formatDobInput`
             &submitVar=`update-date-btn`
             &placeholderPrefix=`spc`
        ]]


        I made two instances of update profile snippet call. Got this idea from something Mark H. pointed out about a posthook. (Though it was off) Figured that the prehook ran EVERYTIME I submitted even if I wasn’t editing the DOB ... so I made a normal snippet call and a special call for the DOB field.

        That’s it.

        That was the problem, the prehook kept running even when editing something that wasn’t needed.

        Thanks guys. Hope this info helps someone else in the future.
          • 3749
          • 24,544 Posts
          To answer your question -- no, output modifiers never alter the DB - they just "modify" the "output" (hence the name) wink
            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