2

I'm working on a project that has two compound field ("flexifield," or "multifield," if you use CCK3) sections that output content types "rooms" and "levels".

Level is defined first and has a title, a total area and an "above ground" binary value.

Room has a length, width and area, then a level defined by a select box — populated by the first set of fields via the following "allowed value" code:

$result = db_query('SELECT `vid`, `field_level_label_value` FROM `drupal_content_type_meas_areas`;');
while ($item = db_fetch_object($result)) {
$items[$item->vid] = $item->field_level_label_value;
}
return $items;

Alas, while the proper label is available when filling in the fields, when actually viewing the content type, the value of each "level" field is a numerical value, instead of the label defined by the level's "field_level_label" field.

How do I make this field save the field's string value instead of its (I'm guessing) vid?

Thanks!

1 Answer 1

1
$result = db_query('SELECT `vid`, `field_level_label_value` FROM `drupal_content_type_meas_areas`;');
while ($item = db_fetch_object($result)) {
$items[] = $item->field_level_label_value;
}
return $items;

I figured it out -- removing the $item->vid bit as $items' array key results in the proper values.

Oh Drupal, so subtle in its frustrations! :D

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.