Configuration

Configuration values are powered entirely by field types. This section will go over the basics of defining, managing, and using configuration for ad dons.

Configuration Keys

Configuration values are defined by a key and scope. The key is simply the dot namespace of the addon and the configuration field slug.

anomaly.extension.xml_feed_widget::url

Because configuration can support multiple instances of the same addon you must also provide a scope. The scope is any value your decide but i s often an ID of an associated model entry.

Consider the above Dashboard module widget. The widget extension provides a configurable XML URL which you can define per instance. Each instance is tied to a widget entry model that's related to the given dashboard. In this scenario the scope is the ID of the dashboard widget entry model.

Defining Configuration

Configuration is defined using field definitions located in the addon's < code>resources/config/configuration.php file:

<?php

return [
    'url' => [
        'type'   => 'anomaly.field_type.url'
,
        'config' => [
            'default_value' => 'http://www.pyrocms.com/posts/rss.xml',
        ],
    ],
];

Defining Form Sections

You can also quickly define form sections the same as fields. To define sections move your resources/config/configuration.php file to resource s/configuration/configuration.php and include a resources/configuration/sections.php file to define sections. The sections.php file simply returns an array of section definitions:

<?php

return [
    'general'      => [
        'context' => 'info',
        'title'   => 'example.module.test::l
abel.general',
        'fields'  => [
            'name',
            'description',
        ],
    ],
];

Displaying Configuration Forms

Configuration can be set by API just like any other Stream entry however you may want to display a configuration form.

To get started you can extend or inject the \Anomaly\ConfigurationModule\Configuration\Form\ConfigurationFormBuilder class. The entry value for configu ration form builders are the addon's dot namespace:

use \Anomaly\ConfigurationModule\Configuration\Form\ConfigurationFormBuilder;

public function edit(ConfigurationF
ormBuilder $builder, $id)
{
    return $builder
        ->setScope($id)
        ->render('anomaly.extension.xml_feed_widget');
}

The configuration form builder is not much different than any other form builder so go crazy and extend or customize as needed in your own project.{.tip}