PHPackages                             contao-community-alliance/events-create-options - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. contao-community-alliance/events-create-options

ActiveContao-module[Utility &amp; Helpers](/categories/utility)

contao-community-alliance/events-create-options
===============================================

options\_callback event and helpers for Contao Open Source CMS

1.0.1(7y ago)03.2k20LGPL-3.0-or-laterPHPPHP ^5.6 || ^7.0

Since Jun 5Pushed 7y ago8 watchersCompare

[ Source](https://github.com/contao-community-alliance/events-create-options)[ Packagist](https://packagist.org/packages/contao-community-alliance/events-create-options)[ RSS](/packages/contao-community-alliance-events-create-options/feed)WikiDiscussions master Synced yesterday

READMEChangelogDependencies (3)Versions (4)Used By (20)

Events: Create options
======================

[](#events-create-options)

Event and helper classes to provide option\_callback's via events.

In your DCA, define the `options_callback` with the factory class `CreateOptionsEventCallbackFactory`.

```
use ContaoCommunityAlliance\Contao\Events\CreateOptions\CreateOptionsEventCallbackFactory;

$GLOBALS['TL_DCA']['tl_foo']['fields']['some_select'] = array(
	'inputType' => 'select',
	...
	'options_callback' => CreateOptionsEventCallbackFactory::createCallback('tl_foo.some_select.create-options'),
);
```

Now you can fill the options with an event listener, listening on the event named `tl_foo.some_select.create-options`.

```
$GLOBALS['TL_EVENTS']['tl_foo.some_select.create-options'][] = function($event) {
	$options = $event->getOptions();

	$options['value1'] = 'label 1';
	$options['value2'] = 'label 2';
	$options['value3'] = 'label 3';
};
```

Manipulate the options with a second event listener is pretty easy.

```
$GLOBALS['TL_EVENTS']['tl_foo.some_select.create-options'][] = array(
	function($event) {
		$options = $event->getOptions();

		// remove a default value
		unset($options['value2']);

		// add a new value
		$options['value4'] = 'label 4';
	},
	-10 // we need a lower priority here, to make sure this listener is triggered after the default listener
);
```

See the [event dispatcher documentation](https://github.com/contao-community-alliance/event-dispatcher#listen-on-events)for more examples how to listen on an event.

Custom event
------------

[](#custom-event)

By default, an event of type `ContaoCommunityAlliance\Contao\Events\CreateOptions\CreateOptionsEvent` is used. If you want your own event type, you can pass the class or a factory method as second parameter to `CreateOptionsEventCallbackFactory::createCallback()`.

First you need to write your own create-options event class.

```
class MyCreateOptionsEvent extends \ContaoCommunityAlliance\Contao\Events\CreateOptions\CreateOptionsEvent
{
	protected $additionalData;

	function __construct($additionalData, \DataContainer $dataContainer, \ArrayObject $options = null)
	{
		parent::__construct($dataContainer, $options);
		$this->additionalData = $additionalData;
	}

	public function getAdditionalData()
	{
		return $this->additionalData;
	}
}
```

Then you need to add your factory to `CreateOptionsEventCallbackFactory::createCallback()`.

```
use ContaoCommunityAlliance\Contao\Events\CreateOptions\CreateOptionsEventCallbackFactory;

$GLOBALS['TL_DCA']['tl_foo']['fields']['some_select'] = array(
	'inputType' => 'select',
	...
	'options_callback' => CreateOptionsEventCallbackFactory::createCallback(
		'tl_foo.some_select.create-options',
		function($dataContainer) {
			return new \MyCreateOptionsEvent(array('some' => 'value'), $dc);
		}
	),
);
```

###  Health Score

32

—

LowBetter than 72% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity16

Limited adoption so far

Community27

Small or concentrated contributor base

Maturity60

Established project with proven stability

 Bus Factor1

Top contributor holds 77.8% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~1462 days

Total

2

Last Release

2898d ago

PHP version history (2 changes)1.0PHP &gt;=5.3

1.0.1PHP ^5.6 || ^7.0

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/44649522?v=4)[xtra](/maintainers/xtra)[@xtra](https://github.com/xtra)

![](https://avatars.githubusercontent.com/u/10211934?v=4)[Chibineko](/maintainers/Chibineko)[@chibineko](https://github.com/chibineko)

![](https://avatars.githubusercontent.com/u/8189209?v=4)[netzmacht](/maintainers/netzmacht)[@netzmacht](https://github.com/netzmacht)

![](https://avatars.githubusercontent.com/u/8672569?v=4)[California College of Arts](/maintainers/cca)[@cca](https://github.com/cca)

---

Top Contributors

[![tristanlins](https://avatars.githubusercontent.com/u/343404?v=4)](https://github.com/tristanlins "tristanlins (7 commits)")[![baumannsven](https://avatars.githubusercontent.com/u/2493263?v=4)](https://github.com/baumannsven "baumannsven (2 commits)")

---

Tags

eventcontaooptions\_callback

### Embed Badge

![Health badge](/badges/contao-community-alliance-events-create-options/health.svg)

```
[![Health](https://phpackages.com/badges/contao-community-alliance-events-create-options/health.svg)](https://phpackages.com/packages/contao-community-alliance-events-create-options)
```

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
