Skip to content

Setup Collections

Setup Collections allow you to create custom data lists in the Setup area of your application. They are ideal for managing simple lookup tables like countries, categories, or templates without writing any code.

Quick Start

  1. Create a YAML file in app-configs/setup/collections/
  2. The collection automatically appears in the Setup navigation

That's it. No migrations, no models, no controllers required.

YAML Structure

PropertyRequiredDescription
titleYesSingular title (e.g., "Customer")
titleListYesPlural title for the list view (e.g., "Customers")
keyYesUnique identifier in UPPERCASE (e.g., "CUSTOMERS")
buttonListNoButton text for creating new entries
descriptionNoOptional description shown in the detail view
hasPageNoWhether collection entries have a CMS page (default: false)
fieldsYesArray of field definitions

Example: Simple Collection

File: app-configs/setup/collections/customers.yml

yaml
title: Kunde
titleList: Kunden
key: CUSTOMERS
buttonList: 'Neuer Eintrag'
description: ''
hasPage: false
fields:
  - name: model.name
    label: Name
    type: text
    colspan: 6

Example: Collection with Multiple Fields

File: app-configs/setup/collections/invoice_templates.yml

yaml
title: Rechnungsvorlage
titleList: Rechnungsvorlagen
key: INVOICE_TEMPLATES
buttonList: 'Neue Vorlage'
description: ''
fields:
  - name: model.name
    label: Name
    type: text
    colspan: 6
  - name: model.template_path
    label: Template Path
    type: text
    colspan: 6

Using Collections in Other Components

setupCollectionSelect Field Type

Use the setupCollectionSelect field type in your detail YAML files to create a dropdown that displays entries from a Setup Collection:

yaml
- name: detailData.country_id
  label: Country
  type: setupCollectionSelect
  collectionKey: countries
  displayField: name
  colspan: 6

Options:

OptionRequiredDescription
collectionKeyYesThe collection filename without .yml extension
displayFieldNoField to display as option label (default: name)
liveNoEnable real-time updates
requiredNoShow required indicator

SetupCollectionHelper

For programmatic access to collection data, use the SetupCollectionHelper class:

php
use Noerd\Helpers\SetupCollectionHelper;

// Get field definitions for a collection
$fields = SetupCollectionHelper::getCollectionFields('customers');

// Get table column configuration
$tableColumns = SetupCollectionHelper::getCollectionTable('invoice_templates');

// Get all available collections
$allCollections = SetupCollectionHelper::getAllCollections();

Available Methods:

MethodReturnsDescription
getCollectionFields(string $collection)?arrayReturns the full YAML configuration including fields
getCollectionTable(string $collection)arrayReturns column definitions for list display
getAllCollections()arrayReturns all collections with their metadata

Available Field Types

All standard field types are supported in Setup Collections. See the Field Types Reference for the complete list, including:

  • text, email, number, date, time, datetime-local
  • textarea
  • select, picklist
  • checkbox
  • relation
  • translatableText, translatableTextarea
  • And more...

Best Practices

  1. Use UPPERCASE keys: The key property should be UPPERCASE and unique (e.g., CUSTOMERS, INVOICE_TEMPLATES)
  2. Keep collections simple: Setup Collections are best for lookup tables with a few fields
  3. Use meaningful names: The filename becomes the collection identifier, so use clear, descriptive names
  4. Localize labels: Use translation keys for field labels to support multiple languages