We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 36875
    • 5 Posts
    I am using the Profile snippet in the Login addon.

    Users can register with a form that has some select boxes that allow multiple values. Among other things, they can choose which languages they speak. For this I have a select box with six languages. The values the user select end up in the database as an extended field which looks like this:

    "languages":["French","Spanish"]

    So far, so good. My question is: how can I render these values in Profile?

    I have tried [[!+languages]] and [[+languages]] but this gives me no output at all. After reading this http://rtfm.modx.com/display/ADDON/Login.Using+Custom+Fields I even tried to do [[+languages.0]], just to see if I would get any output. I didn’t.

    Is what I am trying to do even possible with the Profile snippet?

      • 36875
      • 5 Posts
      I eventually figured something out but I don’t like it much.

      Complex field values (i.e. field values which are kind of like arrays) are accessed like this: [[+complexfield0]], [[+complexfield1]] etc. And NOT, as the docs suggest like this: [[+complexfield.0]], [[+complexfield.1]].

      So, to summarize: if you have something in your registration form like this:

      <select value="" size="5" multiple="multiple" id="languages" name="languages[]">
        <option value="French">French</option>
        <option value="English">English</option>
        <option value="Spanish">Spanish</option>
        <option value="Dutch">Dutch</option>
        <option value="Chinees (Cantonese)">Chinees (Cantonese)</option>
        <option value="Chinees (Mandarin)">Chinees (Mandarin)</option>
      </select>


      And the user selects French and English, you will have the render this in the user’s profile page like this:
      [[+languages0]], [[+languages1]]


      Of course, this means that you’ll first have to figure out how many values the user selected. This all seems very cumbersome to me. Isn’t there a better way?