We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 36805
    • 354 Posts
    Validation of Manager Fields is a common requirement for countless scenarios. What if I want to require a value to be not empty. What if i need a TV to be a number in a specific format. Or an entry to be only composed of max. 2 words. Or really anything I could accomplish with a regexp. What if i want to use the api to restrict it’s value dependending on the document tree position or the selected template.

    I could not believe this is not possible at first and have searched a lot. I came across the MM addon and tried it. It is okay but limited to javascript validation. If your input validation is important that’s a nice addition to serverside checks but not more.

    Do I really need to put the entire manager aside and code a Pubkit like frontend management UI?

    There are plugin events that are triggered which makes you believe you could roll any kind of validation easily. As it turns out you cannot have a plugin show a message in the manager or prevent the saving event itself. Why the heck not? I thought MODx’s strength is supposed to lie in customization!

    -
    To be fair I’ve seen a pioneer case where something like this has worked in revolution. The redirect approach still feels like a workaround needed because validation extensibility is simply missing. Also I need it in Evolution and I need it to be feasible without too much effort and I’m very frustrated by this.
      • 3677
      • 130 Posts
      Found this post and was disappointed to see 0 replies. I’m hoping to do something similar in Revolution.

      For example I have a tv field that needs to contain 10 digits to be valid. I want to perform validation on this field when a radio button state is changed (On/Off) or at least before saving the document. If validation fails I need to display a message regarding the tv field being improperly formatted.

      Is there a way?
        • 18373 ☆ A M B ☆
        • 3,141 Posts
        Think this is coming in 2.1. Can’t find where I found that though.

        If you feel adventurous, you could fetch Revolution from github (see the RTFM for instructions) and see how it looks. I think it’s in there already. tongue
          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.
          • 28042 ☆ A M B ☆
          • 24,524 Posts
          Evo 1.0.5’s new custom TVs should be able to do this; the custom TV is pretty much whatever you want it to be.
            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