We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 36565
    • 73 Posts
    Hello everyone,

    I would like to pass another field value to a custom validator. I have been trying the following to no avail:
    [[!FormIt?
       &preHooks=`CDLaden`
       &customValidators=`freieArchivnummer`
       &validate=`archivhidden:freieArchivnummer=^[[+fi.cdnr]]^`
       &hooks=`CDSpeichern,redirect`
       &redirectTo=`3`
       &submitVar=`abschicken`
    ]]

    Problem is, the tag that is the validate parameter doesn't get parsed, it arrives as the string that it is. Is there an easier way to pass another field value to the custom validator freieArchivnummer?

    Thanks a bunch!
    René
      PHP illiterate MODx enthusiast
      • 3749
      • 24,544 Posts
      You might try setting the fi.cdnr placeholder in an another snippet with $modx->setPlaceholder('fi.cdnr', $value). Put the tag for that snippet above the FormIt tag.

      You could also try making that placeholder uncached, but I don't know if it would help:

      [[!++fi.cdnr]]



      ------------------------------------------------------------------------------------------
      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
        • 36565
        • 73 Posts
        Hey Bob,

        thanks for your answer! I chose the extra snippet that sets the placeholder, and that works so far.

        So does the parsing fail because all these embedded tags don't get parsed, or because that one placeholder is not set at parse time?

        Thanks!
        PS: I love TOG!
          PHP illiterate MODx enthusiast
          • 3749
          • 24,544 Posts
          The placeholder isn't set at the time the snippet tag is parsed. Tags for unset placeholders just get removed when they're parsed, so by the time the that info is needed, it isn't there.

          If the page is cached (and I think it must be to cause the problem), you can look at the cached version of it in core/cache and see what's happening.

          I'm not an expert on parsing order, but I suspect that because the snippet is uncached, the snippet tag is intact in the cached version of the resource, but when the page cache is created, the placeholder tag is not set and gets removed from the cached version of the snippet tag.

          Making the placeholder tag uncached might delay its processing so that it would still be in the cached version of the snippet tag rather than being removed.


          ------------------------------------------------------------------------------------------
          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