I'm about as stuck as can be.

I've created a field and used the key|label input method in the Allowed Values list entry area. What I would now like to do is create a select list and populate it with labels from my allowed values list.

I thought this would be a relatively simple matter of querying the db to retrieve the label values, but the key|label pairings are stored in the global_settings column in the content_node_field table and I can't for the life of me figure out how to retrieve them.

I hate to even ask this, because I'm almost certain the solution is staring me in the face and I'm just experiencing a noob moment, but I really seem to be stuck.

Some background:

* I've tried various takes on print $node->field_csclubs[0]['view']; - can't seem to get this to display anything, no matter what I do.

* I've researched using node reference and Views to solve my dilemma, but can't wrap my head around either. I do need to filter the labels that will be used to populate the list against a user's nid, which would seem like something I could use Views to do, but again, I'm just stumped.

Is there something obvious I'm missing?

Thanks in advance for help.

Comments

yched’s picture

Status: Active » Postponed (maintainer needs more info)

I don't think I get your request. If you've populated the 'allowed values' setting with key|label pairs, then using the 'Select' widget should have the select list you want appear in node forms ?

intent’s picture

My apologies - I didn't provide enough information.

Essentially, I want users to be able to select from a list of physical locations when registering. These locations are clubs of which they are a member. I'm using Content Profile to manage this and all works well. I manage the field with checkboxes because users are allowed to select multiple clubs.

So, my allowed values list looks something like this:

a|Club A
b|Club B
c|Club C
d|Club D

The problem I'm running into is, I'm trying to code a page where, based on the user's uid, a select list is populated with the name of the clubs to which the member belongs. I can see that the key part of the key|label is stored in the field_[fieldname]_value field in the content_field_[fieldname] table, and the key|label pairing is stored in the global_settings field in the content_node_field table. What I don't understand is, how do I retrieve the label from the global_settings field so that I can use it in a select list?

I know the value, of course, and I'm sure there must be some way to retrieve the associated label, I just can't for the life of me figure out what that way is.

intent’s picture

Status: Postponed (maintainer needs more info) » Active
yched’s picture

I'm pretty sure Content Profile has some way to let you display some fields from the profile node on the user's page.
However, if you want / need to display this information manually from the raw field values, you can use

$field = content_fields($field_name, $node_type_name);
$allowed_values = content_allowed_values($field);

to retrieve an array of values keyed by aliases

intent’s picture

Edited the questions I had posted here, as I was able to resolve.

Thanks much for your help ... very much appreciated.

intent’s picture

Status: Active » Closed (fixed)