How to Link Classes.

Adam Jackman-Moore asked on August 11, 2014 04:00

So i found the user class in the membership module, how I am curious how i link classes to it. Say I create a class called UserImages that I want to link to one User, then how do i go to set this link up?

Correct Answer

Brenden Kehren answered on August 12, 2014 13:32

Creating a M:N class like Yehuda suggests does work although sometimes you simply need a dropdown list or a selector that returns the Users ID and that's it.

If this is the case you can add a field in he UserImages doc type or class or custom table and set the datatype as an int. Then pick either a dropdown list and populate the values with a manual list, sql query or a macro OR pick a User Selector as your form control and save. This will simply return a user id for you to store in your other table without the need to create a M:N class/table.

1 votesVote for this answer Unmark Correct answer

Recent Answers

Yehuda Lando answered on August 11, 2014 09:40

I guess you use v8. You can add a M:N class, and add two PK fields two it. One field UserID, and one UserImageID. For the UserID, set "Reference to" to User and "Reference type" to Binding. For UserImageID set "Reference to" to your UserImages class, and also as binding.

Then you can use a User Selector for the UserID and a UniSelector for the UserImageID. I can explain how to set up the UniSelector if you want.

0 votesVote for this answer Mark as a Correct answer

Adam Jackman-Moore answered on August 13, 2014 09:26

This is more in relation to creating a user front end web part for this module back end. I guess Brenden your way is easier for this solution as I will just grab the current userId logged in and assign it that value.

Fairly simple enough but not really enforced by the class structure. Meh it will work eitherway.

Cheers Guys.

0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.