node_reference.devel_generate.inc 837 B

12345678910111213141516171819202122
  1. <?php
  2. // $Id: nodereference.devel_generate.inc,v 1.1 2010/01/28 21:06:42 weitzman Exp $
  3. function node_reference_devel_generate($object, $field, $instance, $bundle) {
  4. if (field_behaviors_widget('multiple values', $instance) == FIELD_BEHAVIOR_CUSTOM) {
  5. return devel_generate_multiple('_node_reference_devel_generate', $object, $field, $instance, $bundle);
  6. }
  7. else {
  8. return _node_reference_devel_generate($object, $field, $instance, $bundle);
  9. }
  10. }
  11. function _node_reference_devel_generate($object, $field, $instance, $bundle) {
  12. $object_field = array();
  13. $allowed_values = node_reference_potential_references($field);
  14. // unset($allowed_values[0]);
  15. if (!empty($allowed_values)) {
  16. // Just pick one of the specified allowed values.
  17. $object_field['nid'] = array_rand($allowed_values);
  18. }
  19. return $object_field;
  20. }