Skip to content

Instantly share code, notes, and snippets.

@anarchivist
Created December 24, 2009 17:23
Show Gist options
  • Select an option

  • Save anarchivist/263275 to your computer and use it in GitHub Desktop.

Select an option

Save anarchivist/263275 to your computer and use it in GitHub Desktop.
UUID Computed Field for Drupal
<?php
/* Autopopulates a Drupal Computed Field [1] CCK field using the UUID module [2].
Requires the 6.x-1.x-dev version of the module UUID, with a specific patch [3].
It assumes that you only want to generate UUIDs once. It probably should be
abstracted into another CCK module, but I'm too lazy to do that at the moment.
[1] http://drupal.org/project/computed_field
[2] http://drupal.org/project/uuid
[3] http://drupal.org/node/502622#comment-1858190
*/
if (empty($node_field[0]['value'])) {
$node_field[0]['value'] = uuid_uuid();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment