Skip to content

Connection Config Fields

Reference for all field types in App\ConnectionConfig\Fields\. Fields are used to build a ConnectionConfigSchema, which the widget API serializes to JSON for the connection widget to render as a form.

For step-by-step usage, see Implement Connection Config.

Common API

All field classes extend AbstractField. Every field supports these fluent methods:

Method Signature Description
make() static make(string $name): static Factory — creates a new field instance with the given name.
label() label(string $label): static Human-readable label shown above the field in the widget.
required() required(bool $required = true): static Marks the field as required. Rendered with a red asterisk; the form submit is blocked until the field has a value.

Every field serializes to at minimum:

{
    "type": "...",
    "name": "field_name",
    "label": "Human label",
    "required": true
}

SelectField

Class: App\ConnectionConfig\Fields\SelectField Widget rendering: dropdown (<select>)

SelectField::make('direction')
    ->label('Sync direction')
    ->options(SyncDirection::cases())
    ->required()

Serialized shape

{
    "type": "select",
    "name": "direction",
    "label": "Sync direction",
    "required": true,
    "options": [
        { "value": "inbound",  "label": "Inbound" },
        { "value": "outbound", "label": "Outbound" }
    ]
}

options() input formats

->options() accepts three forms:

Input Example Behaviour
list<BackedEnum> SyncDirection::cases() Each case becomes one option. Value is $case->value; label is $case->label() if HasLabel is implemented, otherwise $case->name.
class-string<BackedEnum> SyncFrequency::class All cases of the enum are used. Same label resolution as above.
array<string, string> ['inbound' => 'Inbound', 'outbound' => 'Outbound'] Keys become value; array values become label.

Pass list<BackedEnum> (a subset of ::cases()) to restrict the options to what the integration actually supports, rather than every value in the global enum.


MultiSelectField

Class: App\ConnectionConfig\Fields\MultiSelectField Widget rendering: grouped checkboxes

MultiSelectField::make('data_types')
    ->label('Data to sync')
    ->options(SyncDataType::cases())
    ->required()

Serialized shape

{
    "type": "multiselect",
    "name": "data_types",
    "label": "Data to sync",
    "required": true,
    "options": [
        { "value": "customers", "label": "Customers" },
        { "value": "orders",    "label": "Orders" }
    ]
}

options() input formats

Identical to SelectField — see above. The saved value is a JSON array of the selected value strings, e.g. ["customers", "orders"].


RadioField

Class: App\ConnectionConfig\Fields\RadioField Widget rendering: inline radio buttons

RadioField::make('frequency')
    ->label('Sync frequency')
    ->options(SyncFrequency::class)
    ->required()

Serialized shape

{
    "type": "radio",
    "name": "frequency",
    "label": "Sync frequency",
    "required": true,
    "options": [
        { "value": "hourly",  "label": "Hourly" },
        { "value": "daily",   "label": "Daily" },
        { "value": "weekly",  "label": "Weekly" }
    ]
}

options() input formats

Identical to SelectField — see above. The saved value is a single value string.


ToggleField

Class: App\ConnectionConfig\Fields\ToggleField Widget rendering: checkbox

ToggleField::make('include_tax')
    ->label('Include tax in order totals')
    ->required()

Serialized shape

ToggleField has no options key — the only serialized keys are the common ones:

{
    "type": "toggle",
    "name": "include_tax",
    "label": "Include tax in order totals",
    "required": true
}

The saved value is a JSON boolean: true or false.


ConnectionConfigSchema

Class: App\ConnectionConfig\ConnectionConfigSchema

Wraps an ordered list of fields and serializes them as { "fields": [...] }.

ConnectionConfigSchema::make([
    SelectField::make('direction')->label('Sync direction')->options(...)->required(),
    MultiSelectField::make('data_types')->label('Data to sync')->options(...)->required(),
]);

Serializes to:

{
    "fields": [
        { "type": "select", "name": "direction", ... },
        { "type": "multiselect", "name": "data_types", ... }
    ]
}

Fields are rendered in the order they appear in the array.


HasLabel enum interface

If a BackedEnum passed to ->options() implements App\Contracts\HasLabel, the widget label for that case is taken from $case->label() instead of $case->name. Implement this interface on any enum where the PHP case name would be a poor display label.

Source files

File Purpose
app/ConnectionConfig/Fields/AbstractField.php Base class — make(), label(), required(), baseArray()
app/ConnectionConfig/Fields/SelectField.php SelectField with shared resolveOptions() logic
app/ConnectionConfig/Fields/MultiSelectField.php MultiSelectField — extends SelectField
app/ConnectionConfig/Fields/RadioField.php RadioField — extends SelectField
app/ConnectionConfig/Fields/ToggleField.php ToggleField
app/ConnectionConfig/ConnectionConfigSchema.php Schema wrapper
app/Contracts/HasConnectionConfiguration.php Plugin interface: connectionConfigurationSchema() + defaultConnectionConfiguration()
app/Contracts/ConnectionConfigContract.php Config class interface: schema(), supportedDataTypes(), supportedDirections(), defaultConfiguration()
app/Contracts/HasLabel.php Optional enum interface for custom display labels

See also