Thank you for such a wonderful contribution.

I'm not sure if this is a feature request or an oversight. Unlike most other field types, userreference does not have an "allowable values" options. I specifically would like to force users of a particular role to only be able to select themselves, while users of another role can select any user.

Thank you.

Comments

yched’s picture

Category: feature » support
Status: Active » Fixed

Hm. Right now, using 'Views' mode is way to set complex 'referenceable' rules. This specific rule, however cannot currently be defined out of the box using a View, AFAIK, and you'll need to write your own specific Views filter for this

Maybe another way to get this would be :
- use content_permissions module to deny some roles the 'edit' rights on this field,
- in a custom module, on hook_nodeapi('insert' / 'update'), force the only valid value (current user) into $node->field_foo[0]['uid']
your hook_nodeapi() has to take $node param by reference
you need to make sure your hook runs before CCK's (setting your module's weight to -1)

akolahi’s picture

Thank you. What is meant by "'Views' mode". Do you mean views can be used to create CCK forms?

Also, content_permissions would not work since users who don't have 'edit' rights for a field don't take any value for that field, not even the default value (even if the field is required).

Is there a reason why having the 'allowable values' option for userreference would not be a good idea? Seems to me it would be handy for many such reasons... i.e. if you belong to a certain role, your available options are x...

akolahi’s picture

For clarification, other field types call this option "Allowed Values" not "Allowable Values". Sorry for the mixup. Allowed values can take either a list of allowed values or PHP code....

akolahi’s picture

Category: support » feature
Status: Fixed » Active

Haven't heard anything from yched for a couple days. I'm hoping this is a reasonable feature request as it would be a very helpful addition to CCK.