Configuration

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]"
    ]
]
Configuration
Key Example Description
default_value anomaly.module.files The default value.
type module If defined only addons of the specified type will be displayed. Valid options are `module`, `field_type`, `plugin`, `module`, and `extension`.
search anomaly.module.users::authentication.* The extension search option will search and return only extensions with a provision string that matches your search.
theme_type admin Restrict what type of themes are returned. Valid options are `admin` or `standard`.
handler [code>Example/Test/[email protected]](mailto:code>Example/Test/[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) {
    $fieldType->setOptions(
        [
            "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)
    {
        $fieldType->setOptions(
            [
                "anomaly.module.example" => 'Example'
            ]
        );
    }
}