Attribute Type User

Permalink
Hi
I need to be able to assign another user (parent) to a user. Unfortunately I couldn't find this datatype in the attributes. How can I create a new Attribute Type where I can select another user. I think of an integer field where I'll store the userid of the parent but I'll need a dropdown or a list where I can select a parent (user) when I'm editing the child (user).
Any tipps on how to achieve this will be greatly appreciated.
Thanks
Oliver

 
JohntheFish replied on at Permalink Reply
JohntheFish
There are page select and fileset select attributes in the marketplace, but no user select attributes.

Either the page or fileset select attribute may be a good starting point for coding a new attribute type, swapping out the page/file picker widget for a user picker widget.

Attributes can be quite simple to code, but the documentation, examples and hence general community wisdom is no-where near as good as it is for coding blocks, especially as it all changed for v8.
olivero replied on at Permalink Reply
Thank you for the reply.
I used the link below to create a custom user attribute:
https://documentation.concrete5.org/developers/attributes/creating-c...
jasteele12 replied on at Permalink Reply
jasteele12
That sure seems like a lot of work for something functionally fairly simple, and a real pain if you wanted to add more values in the future.

I'd love to hear more about what hereNT mentions at the bottom of that page:

hereNT | Posted on Dec 31, 2016

I've used this technique extending the number attribute for years, it's been handy on tons of sites. The only real difference was that I didn't make up any kind of custom object for the dropdown values, instead just used a basic database query for name / id. Sometimes that's all you really need for a quick and dirty attribute type in an application.
hereNT replied on at Permalink Reply
hereNT
There's not much to it, really. Just extending the number or text attribute and overriding the form to have a dropdown menu that's hardcoded or comes from a database table. I admit it's been awhile since I had to use it, so I don't remember many specific use cases but know that it's been handy when a full blown select doesn't make sense, or if there's a table that needs to be joined through.
hereNT replied on at Permalink Reply
hereNT
Huh. Apparently I made a tutorial package showing how to do it. Completely forgot about that.

https://github.com/herent/c5_tutorials_database_attribute...
drumrby replied on at Permalink Reply
drumrby
I am looking to do this exact same thing as you describe in your original post (attach one user to another user). Would you mind sharing a little more information as to how you accomplished this?