aryehraber/statamic-uuid

One of its kind; unlike anything else

Fund package maintenance!
aryehraber

Installs: 25 557

Dependents: 1

Suggesters: 0

Security: 0

Stars: 2

Watchers: 3

Forks: 4

Open Issues: 0

Type:statamic-addon

v2.3.0 2024-05-13 11:20 UTC

This package is auto-updated.

Last update: 2024-12-13 12:26:55 UTC


README

One of its kind; unlike anything else

This fieldtype auto-generates UUIDs for empty fields. This can be useful if you need unique, persistent IDs for each row in a Replicator, for example.

Installation

Install the addon via composer:

composer require aryehraber/statamic-uuid

Publish the fieldtype assets:

php please vendor:publish --tag=uuid

Usage

Inside your blueprint, simply use type: uuid and a UUID will be generated for that field if it's blank. Already occupied fields (including previously generated UUIDs) will not be overwritten.

Settings

Example:

Blueprint

fields:
  -
    handle: sections
    field:
      type: replicator
      sets:
        section:
          fields:
            -
              handle: uuid
              field:
                type: uuid
            -
              handle: fields
              field:
                type: replicator
                sets:
                  value:
                    fields:
                      -
                        handle: uuid
                        field:
                          type: uuid
                          id_type: nanoid
                          alphabet: ABCD1234
                          size: 5

Output

sections:
  -
    uuid: 026fd166-8638-4c21-9e38-730b4ab3d4ea
    type: section
    fields:
      -
        uuid: A4C11
        type: value
  -
    uuid: 4a7ce0b0-0483-42d9-a7b0-ce0201dd9c84
    type: section
    fields:
      -
        uuid: B1CB3
        type: value
      -
        uuid: 41CD1
        type: value

Credits

Originally built at Series Eight, now maintained by Aryeh Raber.