PHPackages                             lekoala/silverstripe-modular-behaviour - 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. lekoala/silverstripe-modular-behaviour

ActiveSilverstripe-vendormodule[Utility &amp; Helpers](/categories/utility)

lekoala/silverstripe-modular-behaviour
======================================

Use modular-behaviour.js in SilverStripe

0289JavaScript

Since Aug 10Pushed 2y ago2 watchersCompare

[ Source](https://github.com/lekoala/silverstripe-modular-behaviour)[ Packagist](https://packagist.org/packages/lekoala/silverstripe-modular-behaviour)[ RSS](/packages/lekoala-silverstripe-modular-behaviour/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

SilverStripe Modular Behaviour module
=====================================

[](#silverstripe-modular-behaviour-module)

[![Build Status](https://camo.githubusercontent.com/a8525a88f408d1c0d2e71bbd522bbbca46fe9ba065715257d4b3ddbe07dac224/68747470733a2f2f7472617669732d63692e636f6d2f6c656b6f616c612f73696c7665727374726970652d6d6f64756c61722d6265686176696f75722e7376673f6272616e63683d6d6173746572)](https://travis-ci.com/lekoala/silverstripe-modular-behaviour/)[![scrutinizer](https://camo.githubusercontent.com/42aceeaa87370fa2e253919816774e18dc4b27920a05bb394bbce0d3b6e095c7/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f6c656b6f616c612f73696c7665727374726970652d6d6f64756c61722d6265686176696f75722f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/lekoala/silverstripe-modular-behaviour/)[![Code coverage](https://camo.githubusercontent.com/a04797614afb72d52bb1ca8cc348aabc1799a81d3c4845b62eee53f2ae55b8fa/68747470733a2f2f636f6465636f762e696f2f67682f6c656b6f616c612f73696c7665727374726970652d6d6f64756c61722d6265686176696f75722f6272616e63682f6d61737465722f67726170682f62616467652e737667)](https://codecov.io/gh/lekoala/silverstripe-modular-behaviour)

Intro
-----

[](#intro)

Allow usage of [modular-behaviour](https://github.com/lekoala/modular-behaviour.js) in Silverstripe.

ModularBehaviour is a tool that helps you to bind behaviour to a specific html node. As such, it works in a similar fashion than entwine, but works consistently in frontend and backend in a standalone fashion, because forcing usage of entwine in the frontend is not always feasible.

How to use
----------

[](#how-to-use)

Simply extend `ModularFormField` instead of `FormField`. If it's not possible, simply use the `ModularBehaviour` trait. This module is mainly built with FormFields in mind, but it should work just fine for widgets, etc.

You can then override as needed any of the built in methods:

- getModularManual
- getModularSrc
- getModularSelector
- getModularFunc
- getModularName
- getModularConfig
- getModularConfigName

Please refer to the phpdoc for detailed usage.

Here is an example:

```
class MyModularField extends ModularFormField {
    public function getModularName()
    {
        return 'MyApp.MyModularField';
    }

    public function getModularSelector()
    {
        return '.my-modular-field';
    }

    public function getModularConfigName()
    {
        return str_replace('-', '_', $this->ID()) . '_config';
    }

    public function getModularConfig()
    {
        $script = $this->getInitScript();
        $configName = $this->getModularConfigName();
        $script = "var $configName = $script";
        return $script;
    }
}
```

Lazy
----

[](#lazy)

Fields wrapped by modular behaviour can lazily load themselves (which is very useful when used in long pages or in tabs).

Simply call `setModularLazy` and pass `true` and it should all work magically.

Dynamic src
-----------

[](#dynamic-src)

You can also (lazily if needed) load the source script instead of relying on the requirements api.

Simply override `getModularSrc` to return the public path to the js file that contains the constructor.

ESM Note
--------

[](#esm-note)

Due to ajax scripts being loaded through globalEval and not supporting esm module (export not recognized), the min file is built using iife.

Compatibility
-------------

[](#compatibility)

Tested with ^4.10 but should work on any 4.x projects

Maintainer
----------

[](#maintainer)

LeKoala -

###  Health Score

16

—

LowBetter than 5% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity11

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity21

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% 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.

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/250762?v=4)[Thomas Portelange](/maintainers/lekoala)[@lekoala](https://github.com/lekoala)

---

Top Contributors

[![lekoala](https://avatars.githubusercontent.com/u/250762?v=4)](https://github.com/lekoala "lekoala (14 commits)")

---

Tags

modularmodulesilverstripe

### Embed Badge

![Health badge](/badges/lekoala-silverstripe-modular-behaviour/health.svg)

```
[![Health](https://phpackages.com/badges/lekoala-silverstripe-modular-behaviour/health.svg)](https://phpackages.com/packages/lekoala-silverstripe-modular-behaviour)
```

###  Alternatives

[arrowjustdoit/crontab

Crontab extension for laravel-admin

334.0k](/packages/arrowjustdoit-crontab)

PHPackages © 2026

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