Hello,

I've just started getting going with Drupal 7.

I'm trying to add a weight value to an image. I've created an integer field - widget type Select list and I want to populate the select list. In Drupal 6 (using CCK) it was really easy to use a bit of php like so:

$value = -100;
for( $i = 0; $i <=200; $i++ ) {
$values[$i] = $value++;
}
return $values;

This would populate the select list with integers from -100 to 100. Easy.

Drupal 7 doesn't seem to have this option and seems to expect me to manually add a list of numbers like a non-programmer would have to. Is that so? Please tell me I've just overlooked something.

Any help would be appreaciated.

Comments

skein’s picture

are you using a form_alter to add these values?

also wouldn't range(-100,100); be a bit simpler

Quillz’s picture

In Drupal 6 with CCK, when you add a field (or edit an already added field) there is a textfield for you to enter the allowed values for that field. And under there is a section for you to put some php code. No faffing around with form_alter etc, just all conveniently placed at hand when you create/edit a field in your content types.

But it seems to have been removed in Drupal 7 and it seems like a step backwards to me.

skein’s picture

I think the second to last comment here has the answer you're looking for https://drupal.org/node/1717936

Quillz’s picture

Thankyou skein!

For those struggling with the same problem:

Install and enable the CCK module 7.x-3.0-alpha3 (https://drupal.org/project/cck) - this adds CCK stuff that didn't make it to core - and enable the Core module: PHP filter.