We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 8168
    • 1,118 Posts
    Hi guys. I have a member registration form on my new site using Login Register. I have a number of elements in the form which require the member to multi-select an answer - e.g. where are you looking for work: London, South West, Scotland etc etc... What is the best way to do this? I had hoped using a multiple select html input would work (e.g. select dropdown, which allows user to multi-select options), but it appears, only one of the selected items gets passed on member registration - e.g. when I check the member in the MODx manager, always only one of the selected items is saved... Are checkboxes better?

    Oh... and I also need to allow the member to upload a file as part of their registration... Is this possible? I have a file input in the form, but all that is saved and store on registration is the filename... not the file...

    Any advice please?


    Cheers

    dubbs.
      • 3749
      • 24,544 Posts
      You might look at the Subscribe extra. It wraps the Register snippet and makes thing a lot easier. It provides checkboxes for you and saves the values automatically in either the comment field of the User Profile (comma-separated), or in your choice of extended field.

      It's also more secure than Register, imo.
        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
        • 8168
        • 1,118 Posts
        Quote from: BobRay at Sep 19, 2015, 10:27 PM
        You might look at the Subscribe extra. It wraps the Register snippet and makes thing a lot easier. It provides checkboxes for you and saves the values automatically in either the comment field of the User Profile (comma-separated), or in your choice of extended field.

        It's also more secure than Register, imo.

        ok thanks Bob - will take a look wink
          • 8168
          • 1,118 Posts
          Bob - will that also handle file uploading?
            • 3749
            • 24,544 Posts
            No, I'm afraid not, though you might be able to add the FileUpload snippet.
              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
              • 46886
              • 1,154 Posts
              I handle file uploading through the update profile snippet, in my case avatars. I do this as a second step of registering, I think its register -> confirm email -> populate profile and upload pic
                • 8168
                • 1,118 Posts
                Quote from: BobRay at Sep 19, 2015, 10:27 PM
                You might look at the Subscribe extra. It wraps the Register snippet and makes thing a lot easier. It provides checkboxes for you and saves the values automatically in either the comment field of the User Profile (comma-separated), or in your choice of extended field.

                It's also more secure than Register, imo.

                Hi Bob, I'd rather not re-code the Register bits by wrapping in Subscribe... Anyone know how to pass a comma seperated list of values to the user profile field? so e.g.

                Fav Colour - 1) Red, 2) Blue, 3) Green - allow user to select any of the optinos, and pass to the 'FavColour' field as 'red,green' ??

                any ideas?


                Cheers,

                dubbs.
                  • 3749
                  • 24,544 Posts
                  I think that would take a custom hook.
                    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
                    • 8168
                    • 1,118 Posts
                    Quote from: BobRay at Sep 22, 2015, 11:19 PM
                    I think that would take a custom hook.

                    To flatten the array you mean? I can see that using implode to create a comma separated string is what I think I need to do...? But have no idea how to do it in practice as I don't know PHP....
                      • 3749
                      • 24,544 Posts
                      What do the results look like when you submit the form? If the options all have the same name, they will come through as an array based on the 'name' in the form.

                      If the page posts to itself, you can put a snippet at the top with this code:

                      echo print_r($_POST['nameOfField']); It will be empty when the form loads, but it should display the user's choices on submission. If it does, I think the hook will have a reference to the user object, so this should work:

                      $profile = $user->getOne('Profile');
                      if ($profile) {
                          $extended = $profile->get('extended');
                          $variableFromForm = $hook->getValue('variableFromForm');
                          $extended['somefield'] = implode(',', $variableFromForm);
                          $extended->save();
                      }
                        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