The addon field type provides a configurable select dropdown of addons. The field type acts very similar to a relationship between an addon and an entry.


Below is a list of available configuration with default values.

"example" => [
    "type"   => "anomaly.field_type.addon",
    "config" => [
        "default_value" => null,
        "type"          => null,
        "search"        => null,
        "theme_type"    => null,
        "handler"       => "Anomaly\AddonFieldType\Handler\[email protected]"
Key Example Description



The default value.



If defined only addons of the specified type will be displayed. Valid options are module, field_type, plugin, module, and extension.



The extension search option will search and return only extensions with a provision string that matches your search.



Restrict what type of themes are returned. Valid options are admin or standard.


Example/Test/My[email protected]

Handlers let you override control of the options logic.

Option Handlers

Option handlers are responsible for setting the available options on the field type. You can define your own option handler to add your own logic to available dropdown options.

You can define custom handlers as a callable string where @handle will be assumed if no method is provided:

"handler" => /Example/Test/CustomOptions::class // Assumes @handle

Option handlers can also a handler with a closure:

"handler" => function (AddonFieldType $fieldType, ExampleModule $module) {
            "anomaly.module.example" => $module->getName()
Remember: Closures can not be stored in the database so your closure type handlers must be set / overridden from the form builder.
Writing Option Handlers

Writing custom option handlers is easy. To begin create a class with the method you defined in the config option.

"handler" => "App/Example/[email protected]"

The callable string is called via Laravel's service container. The AddonFieldType $fieldType is passed as an argument.

Pro Tip: Handlers are called through Laravel's service container so method and class injection is supported.
<?php namespace App/Example;

class MyOptions
    public function handle(AddonFieldType $fieldType)
                "anomaly.module.example" => 'Example'


This section will show you how to use the field type via API and in the view layer.

Setting Values

You can set the addon field type value with an addon's namespace:

$entry->example = "anomaly.module.files"

You can also set the value with an instance of an addon:

$entry->example = $module;

Lastly you can set the value with an instance of an addon presenter:

$entry->example = $decorated;

Basic Output

The value returned by the field type is either null or an instance of the selected addon.

$entry->example->getNamespace(); // anomaly.module.files

Presenter Output

The addon field type will always return null or an instance of the addon. When accessing the field value from a decorated entry model the returned addon instance will be automatically decorated.

$decorated->example->name; // Files Module
{{ }} // Files Module