We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 38846
    • 30 Posts
    Is this correct thinking.

    To add to extended field? And I am guessing I would need !UpdateProfile? at the beginning.

    Check box:
    <input name="addtorfq[addtorfq]" value="[[~[[+id]]]]" type="checkbox">


    Quantity:
    <input type="text" size="3" maxlength="5" value="1" name="qty1[rfqQTY]">


    Then add a button like:
    <input id="updatesubmit" type="submit" value="Submit Request For Quote" name="login-updprof-btn">



    History: I have created a wishlist using UserValueList which is like cookie list but stores in an extended field rather than in the cookie. For each product added to the list the user wishlist creates a table.

    In that table there is a check box and a quantity box. I am trying to make the checked values populate a quote cart where an email is sent when a submit button is hit and then it is dated and saved for the user to refer to. I then will add a button to remove quotes later and/or set a time period on saved. quotes.
      • 3749
      • 24,544 Posts
      You need &useExtended=`1` in the UpdateProfile snippet tag. http://rtfm.modx.com/display/ADDON/Login.UpdateProfile

      I don't know if UpdateProfile will create new extended fields automatically or not. You may need a preHook that checks whether the field exists and creates it if it's not there.


      ------------------------------------------------------------------------------------------
      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
        • 38846
        • 30 Posts
        Maybe this is a better way of putting it...

        Could you show me a full example of a snippet that would add a extended value of say "selected" as a container and then its value inside?


        Then I am thinking all I have to do it place the prehook for said snippet and create the placeholders for selected and its value in the resource which would be reflected in the database upon submission. Correct?
          • 3749
          • 24,544 Posts
          I don't have one handy. wink

          I'm afraid I can't give you an example because I still don't fully understand what you're trying to do. I'm probably just dense, but I'm confused by how you're using the terms "table" and "container" Each User Profile is stored in the MODX database as a row in the modx_user_attributes table, but there are no tables or containers inside that table.

          Maybe a screen shot of a filled-in extended fields section of the User Profile form would help me understand what you're doing.


          Also, you wouldn't normally create a placeholder in a preHook. Usually, the placeholder tag is in the form and you set the placeholder value in the preHook.

          When the User Profile form is first displayed, do you need it to reflect what's already in the User Profile?

          Will one user have more than one "quote" stored in the database at any time?

          Different users will have different values in the extended fields of the Profile, but will they have different Fields too? This is important because if the possible fields are the same for all users, you could have a utility plugin that created them automatically for new users. Having different fields for different users would generally be a bad practice from a DB design standpoint.

          TBH, it sounds like you may need some custom tables added to the MODX DB for what you're doing -- at least these:

          Customers
          Products
          Quotes
          CustomerQuotes

          Doing it all with resources and extended user fields will be inefficient and slow if you expect to have a lot of customers and/or products.


          ------------------------------------------------------------------------------------------
          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
            • 38846
            • 30 Posts
            Here is the break down with images.


            Link on page to add to wish list - (works fine):


            Link after login - (works fine):


            Those two are basically firing in an If statement.

            Wish List - Gathers the value of UserValueList and places it in a chunk in the wishlist resource:


            Here is where I am at.

            So there are multiple items in a users wish list. They select the ones (or all fired by a bit of javascript) they would like to have a quote for by ticking the check box. Then they enter the quantities of each they would like. Then they submit.....

            When submitted it would fire to save in the users attributes something like this:
             ,"Selected":[],"ID":"","Qty":""}
            where selected would be a "on/off" I am guess 1 or 0 in the braces. Then I would just call if 1 then selected values to chunk for Quote History.

            The submit (which is on there as update profile now) will also fire off an email in a hook, which I already know how to do. Then I will later figure out how to do a time limit and or delete.
              • 3749
              • 24,544 Posts
              I'm still not clear on what you're doing, but maybe this will help:

              To alter extended fields, you'd do something like this:


              <?php
              
              $profile = $modx->user->getOne('Profile');
              
              if ($profile) {
                  $extended = $profile->get('extended');
              
                  /* $extended is now a PHP array of the user's extended fields */
                  // echo print_r($extended, true);
              
                  /* add a new field with a value */
              
                  $extended['color'] = 'red';
              
                  /* save the extended fields back to the DB */
              
                  $profile->set('extended', $extended);
                  $profile->save();
              } else {
                  echo "User Has no Profile";
              }



              ------------------------------------------------------------------------------------------
              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
                • 38846
                • 30 Posts
                That is a good leaping point. Thank you. I will mess around with that and let you know what I come up with.
                  • 38846
                  • 30 Posts
                  Hrm... So just saved that as a snippet and then added a place holder for it on a test page. Viewed the page and nothing was added to the database. Am I being stupid, or shouldn't this add the fields color:red in users attributes?

                    • 3749
                    • 24,544 Posts
                    I did it off the top of my head, but it should work. The data would be in the 'extended' field for that user in the modx_use_attributes table.


                    ------------------------------------------------------------------------------------------
                    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
                      • 11186
                      • 38 Posts
                      I'm having a similar issue. The problem seems to be with Login and the extended fields and their inability to add data to extended field containers via checkbox or select.

                      For example:

                      <input name="container[]" value="[[~[[+id]]]]" type="checkbox">


                      This will work and add an extended field named 'container' with a value of 'id'

                      However, this is what we want:

                      <input name="container[addtorfq]" value="[[~[[+id]]]]" type="checkbox">


                      Which should:

                      A. add an extended field container named 'container' and
                      B. add an extended field in that container named 'addtorfq' with a value of 'id'

                      But it doesn't work. I've scoured the forums for 3 days and the only way I've seen to make this work is by writing custom snippets and using hooks.

                      However, this does work with an input type text. Which to me translates to 'Don't expect to use anything other than text type inputs for register/updateprofile for hierarchical extended field containers, unless you want to write custom snippets.'.

                      Revo 2.2.4
                      Login 1.8.1 [ed. note: grabenfub last edited this post 14 years, 1 month ago.]