You are here

function content_devel_multiple in Content Construction Kit (CCK) 5

Same name and namespace in other branches
  1. 6.3 includes/content.devel.inc \content_devel_multiple()
  2. 6.2 includes/content.devel.inc \content_devel_multiple()

A simple function to return multiple values for fields that use custom multiple value widgets but don't need any other special multiple values handling. This will call the field generation function a random number of times and compile the results into a node array.

1 call to content_devel_multiple()
content.devel.inc in ./content.devel.inc
Functions needed for Devel module integration.

File

./content.devel.inc, line 35
Functions needed for Devel module integration.

Code

function content_devel_multiple($function, $node, $field) {
  $node_field = array();
  if (function_exists($function)) {
    switch ($field['multiple']) {
      case 0:
        $max = 0;
        break;
      case 1:
        $max = rand(0, 3);

        //just an arbitrary number for 'unlimited'
        break;
      default:
        $max = $field['multiple'];
        break;
    }
    for ($i = 0; $i <= $max; $i++) {
      $node_field[$i] = $function($node, $field);
    }
  }
  return $node_field;
}