user_reference.devel_generate.inc 733 B

1234567891011121314151617181920212223
  1. <?php
  2. function user_reference_devel_generate($object, $field, $instance, $bundle) {
  3. if (field_behaviors_widget('multiple values', $instance) == FIELD_BEHAVIOR_CUSTOM) {
  4. return devel_generate_multiple('_user_reference_devel_generate', $object, $field);
  5. }
  6. else {
  7. return _user_reference_devel_generate($object, $field);
  8. }
  9. }
  10. function _user_reference_devel_generate($object, $field) {
  11. $object_field = array();
  12. $allowed_values = user_reference_potential_references($field);
  13. if (isset($allowed_values[0])) {
  14. unset($allowed_values[0]);
  15. }
  16. if (!empty($allowed_values)) {
  17. // Just pick one of the specified allowed values.
  18. $object_field['uid'] = array_rand($allowed_values);
  19. }
  20. return $object_field;
  21. }