Hello I'm trying to add a field with has php code to generate it's list of elementes.

<?php
$result = db_query("SELECT rid, name FROM {role} WHERE  rid NOT IN (:rid)", array(
  ':rid' => 1, 2, 0,3)
));
$roles = array();
foreach($result as $record){
$roles[$record->nid]  = $record->name;
}
return $roles;

?>

I see the select element, but I don's save nothing.

Also it give me this error:

Notice: Undefined property: stdClass::$nid in eval() (line 9 of /var/www/propios/gcms/sites/all/modules/contrib/cck/cck.module(304) : eval()'d code).Notice: Undefined property: stdClass::$nid in eval() (line 9 of /var/www/propios/gcms/sites/all/modules/contrib/cck/cck.module(304) : eval()'d code).

I'm working with php 5.3.3.x

Thanks

Oskar

Comments

kehan’s picture

that would be a typo on your part
should be

$roles[$record->rid]  = $record->name;

not:

$roles[$record->nid]  = $record->name;
oskar_calvo’s picture

Thanks a lot kehan , I don' realize about my mistake.