On March 26, 2019 we launched new MODX Forums. Please join us at the new MODX Community Forums.
Subscribe: RSS
  • Sorry to come back again on this issue, but does anyone can tell me if the Register snippet's &validate actually works ??

    If I validate over any extended fields, then the submit gives back the form page again (but no error place holders appears)
    &validate=`nospam:blank,
      username:required:minLength=^6^,
      password:required:minLength=^6^,
      password_confirm:password_confirm=^password^,
      order_fname:minLength=^2^
    `


    but if I do not validate over an ext field, then everything is ok , all fields (incl. ext fields) are actually created on user's profile.

    Thank you
    • Do you have this in the tag?

      &useExtended=`1`
        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
      • Quote from: BobRay at Jan 30, 2015, 11:04 PM
        Do you have this in the tag?

        &useExtended=`1`

        Yes. Thank you

        And ext fields are actually created when the post 's going well.


        Have a look to my other post about this issue here :
        http://forums.modx.com/thread/95839/login-register-naming-of-extended-fields#dis-post-518873

        there's an issue with the creation of extended fields when using container for them.
        I'd like to organize the ext fields using sub container for them.
        Seams the syntaxe is name=[CONTAINER]name_of_field in forms input.

        With that particular use either I got doublon either I got no container (when validating)

        in the form :
        ...
              <label class=" control-label sr-only" for="order_fname">[[%register.fname]] </label>                                                                         
                <div class="form-group has-feedback" >                                                                                                                                 
                  <div class=" input-group">                                      
                    <span class="input-group-addon">                                            
                      <i class="oi oi-people"></i>                                      
                    </span>                                                                                                      
                    <input class="form-control"  type="text" name="[ORDER]order_fname" id="order_fname" required="required" value="[[!+reg.[ORDER]order_fname]]" placeholder="[[%register.fname]]" />                                             
                  </div> 
                    <span class="alert live alert-warning"  role="alert">                                                    
                      <span class="badge badge-warning">!                                       
                      </span>[[!+reg.error.[ORDER]order_fname]] [[%i18n.required? &language=`[[++cultureKey]]` &namespace=`i18ncustom`]]                                        
                      <span class="label label-warning">Attention                                       
                      </span>                                                
                    </span>          [[!+reg.error.[ORDER]order_fname:notempty=`                                 
                    <span class="alert">                                      
                      <span class="badge badge-warning">!                                       
                      </span>            [[!+reg.error.[ORDER]order_fname]]                                 
                    </span>`]]
                
                </div>    

        ...

        the call:
        [[!Register?
        &submitVar=`registerbtn`
        &activation=`1`
        &activationEmailTpl=`lgnActivateEmailTpl`
        &activationEmailSubject=`Please activate your account!`
        &activationResourceId=`54`
        &submittedResourceId=`53`
        &useExtended=`1`
        &emailField=`order_email`
        
        &usergroups=`Members`
        &validate=`nospam:blank,
          username:required:minLength=^6^,
          password:required:minLength=^6^,
          password_confirm:password_confirm=^password^,
          [ORDER]order_fname:required
        `
        
        
        &placeholderPrefix=`reg.`
        ]]
        • I think each extended field needs a separate input in the form, and that input has to have the same name as the extended field in the DB. I could be wrong.
            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
          • Quote from: BobRay at Feb 02, 2015, 04:45 PM
            I think each extended field needs a separate input in the form, and that input has to have the same name as the extended field in the DB. I could be wrong.
            Yes of course thank you.
            That's what I'm doing... see my form extract up there please.
            The question is out to deal with ext.fields CONTAINERS
            I found I don'i know where it should be done with an in put name= "[CONTAINER]field_name"

            But as I told, THIS seams to bug if trying to &validate over it.

            That's my problem.
            • What is the [CONTAINER] supposed to do? I suspect that the field name is perhaps not valid.

              What does container represent here? If the field name was something like user_field1 and user_field2 I think you would be fine.

              Is container a variable or something?
              • Quote from: nuan88 at Feb 03, 2015, 12:54 PM
                What is the [CONTAINER] supposed to do? I suspect that the field name is perhaps not valid.

                What does container represent here? If the field name was something like user_field1 and user_field2 I think you would be fine.

                Is container a variable or something?
                this is suppose to create the user's profile extented fields WITHIN a sub Container.See ext fields, you can do any sub"folder" to put inside all ext.fields you need to organize them as needed.
                In our cas we will use SimpleCart compnent and need to add a lot of fields (for ORDER data plus DELIVERY data) such as fname, lname, and many more.

                From a form point of view I do not know what is correct but name=[vvvv]xxx create correctly the container but no in all calls (??) and, well, it's very confused.
                • Ok we are talking about in the database. MODX uses a JSON file for these extended fields for user data, the fields are just in a line, age rank serial_number, whatever names you give for them.

                  But you want them in subgroups, according to what? The user is answering questions like what is your age, where do you live, and you are putting that in a *subgroup*?

                  So we have:

                  Name Age Location Level
                  User1 22 Lima Expert
                  User2 47 Caracas Novice
                  User3 18 Bogota Expert

                  This is the normal info in db, and you can query the db to look at info like say average age and what percent are expert or novice, or you could look at only those novice users and their average age.

                  So I don't understand subgroup, maybe the expert or novice value like this can help you? What groups are there and how to decide who goes in what groups?

                  Finally, just to let you know, Class Extender makes this issue much easier, and helps you to use the user data you get. I haven't implemented it yet but it looks promising, its quite new.

                  So, pls tell me your idea more clearly, maybe I can point you in the right direction.
                  • Register can't handle a nested array of extended fields. It assumes that the extended field holds an simple array of keys and values.

                    In addition, this is not a valid value for the name attribute or an input:

                    name="[ORDER]order_fname"


                    The $_POST array will be empty on submission.

                    OTOH, this is valid, but I don't think it will work with the Register snippet:
                       name="order_fname[]"


                    This also returns a value, but if you have more than one order_fname[CONTACT] in the form, the $_POST array will be missing all but one of them.
                    name="order_fname[CONTACT]"


                    The resulting array looks like this (not what you want, I think):

                    array
                      'order_fname' => 
                        array
                          'CONTACT' => string 'hello' (length=5)


                    The only workable solution, if you're going to use the Register snippet, is to have a unique name (with no [] characters) for each extended field you want to store.

                    An alternative would be to handle the extended fields yourself in a preHook or postHook.

                    BTW, user extended fields are not a good place for frequently accessed data. They are slow and cumbersome. If you need to search or sort based on what's in an extended field, you should probably be looking at extending the modUser object: http://bobsguides.com/blog.html/2014/05/27/why-extend-moduser/.
                      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
                    • Class Extender is probably the best solution here. MODX itself doesn't handle custom user data very well to be honest.