We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 29059
    • 88 Posts

    hello,

    in trying to follow the documentation for the Login extra, i've hit a crossroads with how to implement Validation in the Register Form.

    below are two pages from the docs on how to do it, but they're different. which method should i use? if they both work, is there a "best practice" here?

    note: i've intentionally snipped out the non-relevant code from both of these examples. the full thing can be seen at the links provided.

    THANKS!
    -jason.

    https://rtfm.modx.com/extras/revo/login/login.tutorials/login.request-membership >>>
    [[!Register?
         &blahblahblah...
    ]]
    <input type="text" name="username:required:minLength=6" id="username" value="[[+username]]" />


    https://rtfm.modx.com/extras/revo/login/login.register/register.example-form-1 >>>
    [[!Register?
         &blahblahblah...
         &validate=`nospam:blank,
              username:required:minLength=^6^,
    ]]
    <input type="text" name="username" id="username" value="[[!+username]]" />


      • 46886
      • 1,154 Posts
      Here is the one you want, which is I guess the right link but you don't have the right code there:

      https://rtfm.modx.com/extras/revo/login/login.register/register.example-form-1

      I checked mine (I remember I started with this example) and its matching the above form, although its been changed slightly over time.

      I think you have made a mistake in your post, as the code of the above link is:
              <label for="username">[[%register.username? &namespace=`login` &topic=`register`]]
                  <span class="error">[[!+reg.error.username]]</span>
              </label>
              <input type="text" name="username" id="username" value="[[!+reg.username]]" />


      Note your value="[[!+username]] versus the example's [[!+reg.username]]

      Login extra is a little hinky to be honest, but it does work, start with the example and you can customize it quite a lot, but probably best to move slowly, because if you run into trouble the only way out is to go back to the basic one again...I remember I had trouble at one point and simply couldn't see where there could be a problem, but when I started over, it was fine.

      Also be careful with the user group. Not sure if there is a default or if that is what you want.
        • 46886
        • 1,154 Posts
        So, just to be clear, all the validation requirements are in the snippet.

        Its interesting to decide what to require, I have noticed that every developer wants me to use like one upper case, one lower case, one number blah blah, and I am always like, this is a stupid dating site, no one is going to hack my account for pete's sake, just let users make the password of 12345 already haha!~ Joking but it is frustrating when its just a random website.

        For you, as a forum, it may be different, of course, just ranting.
          • 29059
          • 88 Posts
          Quote from: nuan88 at Feb 10, 2016, 08:06 AM
          Here is the one you want, which is I guess the right link but you don't have the right code there:
          https://rtfm.modx.com/extras/revo/login/login.register/register.example-form-1

          okay, so the validation requirements need to be in the [[!Register...]] part and not in the html input name part. great, thank you.
          i sure wish the documentation was more precisely done

          Quote from: nuan88 at Feb 10, 2016, 08:06 AM
          I think you have made a mistake in your post, as the code of the above link is:
          <label for="username">[[%register.username? &namespace=`login` &topic=`register`]]
                      <span class="error">[[!+reg.error.username]]</span>
                  </label>
                  <input type="text" name="username" id="username" value="[[!+reg.username]]">
          Note your value="[[!+username]] versus the example's [[!+reg.username]]

          well, remember, i noted in my original post that i snipped out everything but the part i was asking about.
          but as far as the &placeholderPrefix=`reg.` goes, i removed it intentionally because the documentation says it's only needed if you have more than one form on a page; and since i don't, i left it out. the form seems to work just fine without it. BUT, if this is yet another issue with the documentation being off, then pls lemmeknow & i'll re-add it.

          Quote from: nuan88 at Feb 10, 2016, 08:06 AM
          Login extra is a little hinky to be honest, but it does work, start with the example and you can customize it quite a lot, but probably best to move slowly, because if you run into trouble the only way out is to go back to the basic one again...I remember I had trouble at one point and simply couldn't see where there could be a problem, but when I started over, it was fine.

          YES! it is hinky! that exact same thing happened to me!! weird. i had it running, then did some simple customizations & it stopped working. i spent HOURS troubleshooting it without success; then started over, made the exact same modifications, but this time one-by-one, and it continues to work fine. when i compare the codes, they are the same! hinky indeed!!!

          Quote from: nuan88 at Feb 10, 2016, 08:06 AM
          Also be careful with the user group. Not sure if there is a default or if that is what you want.

          so far in my tests, my custom &usergroups=`Sanctuarian` is working fine. but i'll keep an eye on it, given the hinky'ness of it all ;-)
            • 46886
            • 1,154 Posts
            Ok it seems you read the documentation much more thoroughly than I ever did haha, so if the *reg* can be removed go for it, I didn't understand your point about this. You say it works and that's all that matters.

            Yeah login takes a bit of work but its still ok, it does work and does let you do what you want. Basically Modx loses a bit of ease in getting started in exchange for significant customization capabilities. By comparison, Wordpress for example can get you up and running quickly, but you will start bumping your head on a very hard and unyielding ceiling very quickly, and there are no easy fixes there. I remember trying it and throwing a simple html template in there and it didn't come out looking right, and its hard to fix because somewhere in the bowels of the Wordpress engine its doing funky stuff that only some real experts understand.

            I just mentioned the user group as I know you need to hook it all up to the forum. BTW, you can assign users to multiple groups at once if you want.

            You have made a lot of quick progress! The learning curve is a little steep but it seems you have traversed it already, it gets more fun going forward! smiley

            By the way the *snippet* is the whole part with brackets around it [[ ]], and if I am not mistaken the exclamation point calls the snippet uncached, so its the updated snippet (I might have this a bit wrong, but that matters sometimes, if you had a snippet that got the current user, for instance, you would need to call it uncached for sure.) Snippets are basically tools to do stuff, injecting some dynamic code into a page, this is a major advantage of Modx. In my site I have a tool which grabs the most common words on the current page and searches the database for other pages with those words, so if someone was reading about glassware for instance the snippet would try to provide other pages with that keyword. Ideally this keeps the user clicking and clicking away while learning more and more.

            Chunks, on the other hand, are pieces of more basic code like html, and the idea there is more like having a bit of code in one place, even if it appears in many places, so when you change it you only need to change it in one place. An example here would be, imagine I had 3 sites that all gave the same phone number and contact info, well I can put that content into a chunk and call it on all three sites, but when I change it there is just one location.

            Any more questions just ask.