Populate field with series of numbers computed from separate minimum and maximum fields

sjf - September 1, 2009 - 14:51
Project:Computed Field
Version:6.x-1.x-dev
Component:Documentation
Category:support request
Priority:normal
Assigned:Unassigned
Status:closed
Description

Does anyone have a snippet for populating a computed field with a range of comma-separated numbers based on two user-entered fields - minimum and maximum?

For example, if the user enters 20 in field_value_minimum and 25 in field_value_maximum, the computed field is populated with "20,21,22,23,24,25"

#1

sjf - September 4, 2009 - 10:29

I should probably explain what I'm trying to do. Essentially, I'm looking for a more user-friendly way to enter a range of numeric values than having to type each number into the field comma-separated or selecting each value from a multi-value select list. This is particularly important for large ranges.

I suppose the ideal solution would be a CCK option widget that allows the user to simply enter "20-25" in a single field, and have it stored in the database as "20,21,22,23,24,25". I don't think this is possible at the moment which is why I've turned to Computed Field.

I'm not a coder, but I ran into an article here. Obviously the code below doesn't work but could I do something like this?

foreach(range($node->field_value_minimum[0]['value'], $node->field_value_maximum[0]['value'], 1);
{
    echo implode(', ', $aArray);

The reason I need an array of numbers is so that people can perform a search in Views. For example, if someone searched all nodes that contain the number "23" in a certain field, they wouldn't find my node with the text string "20-25" in that field, but they would find it if it was in the format "20,21,22,23,24,25".

#2

held69 - October 30, 2009 - 15:54

This is exactly what i'm looking for as well.

http://drupal.org/node/616740

Would be great for entering age range in a easy way.

Suggestions on this topic very much appreciated.

Thanks

#3

held69 - November 2, 2009 - 16:23
Status:active» fixed

try measured value field or check

http://drupal.org/node/620484

#4

System Message - November 16, 2009 - 16:30
Status:fixed» closed

Automatically closed -- issue fixed for 2 weeks with no activity.

 
 

Drupal is a registered trademark of Dries Buytaert.