Hi guys,
I need some help with the following:
I use Rules' action "Populate a CCK field" and I need to use PHP to "Specify the fields value with PHP code":
this means this particular node reference cck field is multi-valued and therefore the returned array has an undefined number of rows and depends on the user choice.
I use following code to achieve this
($values is an array containing the Node ID's the user has chosen)
($lastKey is a variable containing the last reference in $values)
return array(
for ($i=0; $i<$lastKey; $i++) {
$i => array('nid' => $values[$i]),
);
}
I get the following error:
"Parse error: parse error, expecting `')'' in C:\xampp\mysite\sites\default\modules\rules\rules\modules\php.rules.inc(107) : eval()'d code on line 39"
Can someone help? This should be a small tweak... Thanks!
Comments
Comment #1
BillyMG commentedUh, I think this is equivalent to what you're trying to do... It's kind of hard to tell from your code.
Comment #2
klausiDoes not look to be rules_forms related.
Comment #3
mitchell commented@mitkoru: any update on this?
Comment #4
drupov commented@opensanta:
I think the solution is in #1. I tried to return an array with an for loop in it. Correct would be to run the for loop first and save it in a variable which to return.
Comment #5
mitchell commented>> I think the solution is in #1.
See also: Array Tokens.