PHPackages                             iliain/silverstripe-droppable - 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. iliain/silverstripe-droppable

ActiveSilverstripe-vendormodule

iliain/silverstripe-droppable
=============================

Provides a field that allows for clicking and dragging of shortcodes into a textarea

2.0.0(1y ago)123BSD-3-ClausePHPPHP ^7 || ^8

Since Nov 29Pushed 1y ago1 watchersCompare

[ Source](https://github.com/Iliain/silverstripe-droppable)[ Packagist](https://packagist.org/packages/iliain/silverstripe-droppable)[ Docs](http://github.com/Iliain/silverstripe-droppable)[ RSS](/packages/iliain-silverstripe-droppable/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (8)Dependencies (1)Versions (10)Used By (0)

Silverstripe Droppable Textarea
===============================

[](#silverstripe-droppable-textarea)

[![Latest Stable Version](https://camo.githubusercontent.com/c13fd322836ba4d3095b627cef9866cfae2f99aecc0397851a20e51b6544acc4/68747470733a2f2f706f7365722e707567782e6f72672f696c6961696e2f73696c7665727374726970652d64726f707061626c652f76)](https://packagist.org/packages/iliain/silverstripe-droppable) [![Total Downloads](https://camo.githubusercontent.com/e9d32c8d6451481687526bd3d72ed1486ebb9584ae6616f2e9e66f65a50ca20b/68747470733a2f2f706f7365722e707567782e6f72672f696c6961696e2f73696c7665727374726970652d64726f707061626c652f646f776e6c6f616473)](https://packagist.org/packages/iliain/silverstripe-droppable) [![Latest Unstable Version](https://camo.githubusercontent.com/627e0c641355b785081a236190f45258e09e54aa7f41a302322a6728221ebff0/68747470733a2f2f706f7365722e707567782e6f72672f696c6961696e2f73696c7665727374726970652d64726f707061626c652f762f756e737461626c65)](https://packagist.org/packages/iliain/silverstripe-droppable) [![License](https://camo.githubusercontent.com/5ae18ffb0c82eedb7d470ebd458c6ea20fc18488af8484d5775fbf334bae6dfa/68747470733a2f2f706f7365722e707567782e6f72672f696c6961696e2f73696c7665727374726970652d64726f707061626c652f6c6963656e7365)](https://packagist.org/packages/iliain/silverstripe-droppable) [![PHP Version Require](https://camo.githubusercontent.com/c573514ab7911c3338bd3db64cc6ffef10e9448fff42bc217c57c6dab00f5d52/68747470733a2f2f706f7365722e707567782e6f72672f696c6961696e2f73696c7665727374726970652d64726f707061626c652f726571756972652f706870)](https://packagist.org/packages/iliain/silverstripe-droppable)

Provides a field that allows for clicking and dragging of shortcodes into a related field. Useful for inserting shortcodes into a textarea without having to type them out.

NOTE: This only allows the insertion of shortcodes, it does not provide any functionality for parsing the shortcodes themselves.

Installation (with composer)
----------------------------

[](#installation-with-composer)

```
composer require iliain/silverstripe-droppable

```

Requirements
------------

[](#requirements)

- PHP 7.4+ or 8.0+
- Silverstripe 4+ or 5+

Usage
-----

[](#usage)

The following is an example of creating a textarea and droppable field, assigning buttons to the different rows, and pushing a button to an existing row. Each option/button will be an array, with the first element being the shortcode to insert, and the second being the text to display on the button.

```
use Iliain\Droppable\Fields\DroppableField;

$blockContent = TextareaField::create('BlockContent', 'Block Content');

$droppable = DroppableField::create('Example', 'Example', 'BlockContent')
    ->setButtonRow(0, [
        ['[OPTION_1]', 'Option 1'],
        ['[OPTION_2]', 'Option 2'],
    ])
    ->setButtonRow(1, [
        ['[OPTION_3]', 'Option 3']
    ])
    ->pushButton(1, ['[OPTION_4]', 'Option 4']);
```

[![Animated example of the field being used](client/images/usage-example.gif)](client/images/usage-example.gif)

You can also use the method `->setUseDropdown(true)` to use a dropdown instead of buttons. This will use the same data as the buttons, but will be displayed in a dropdown instead. This is useful when dealing with large amounts of buttons.

[![Animated example of using the dropdown](client/images/usage-example-2.gif)](client/images/usage-example-2.gif)

From here, the user can either:

- Click on a button to insert the shortcode into the start of the textarea, or the current position if the field is currently selected
- Drag a button into the textarea to insert the shortcode at the cursor position

Additionally, the field can be swapped to 'wrap' mode, which will wrap a defined set of code around the users current selection. It will look for `$1` and `$2` in the supplied string, and replace them with the selected text and the button value respectively.

```
$droppable->setWrapSelection(true);
$droppable->setWrapElement('$1');
```

The above would result in the following when clicking the first button while selecting "Selected Text" in the following sentence:

```
This is the Selected Text

This is the Selected Text
```

Functions
---------

[](#functions)

Has the usual functions available to a TextareaField, plus:

- `setButtonRow(int $row, ArrayList $buttons)` - Sets the buttons for a particular row. The buttons are an array of arrays. Will overwrite any existing buttons in that row.
- `getButtonRow(int $row)` - Gets the buttons for a particular row. Useful for modifying an existing row without just appending to the end.
- `pushButton(int $row, array $button)` - Pushes a button to the end of a particular row. Will append to an existing row, or create a new row if it doesn't exist.
- `setUseDropdown(bool $useDropdown)` - Sets whether to use a dropdown instead of rows of buttons. Defaults to false. The dropdown will use the row order as the order of the dropdown items.
- `setWrapSelection(bool $wrap)` - Sets whether to wrap the selection with the button value. Defaults to false.
- `setWrapElement(string $wrap)` - Sets the string to use for wrapping. Defaults to `$1`. The `$1` will be replaced with the selected text, and the `$2` will be replaced with the button value.

TODO
----

[](#todo)

- Minify the JS and CSS
- Allow setting of default dropdown text

###  Health Score

30

—

LowBetter than 64% of packages

Maintenance48

Moderate activity, may be stable

Popularity8

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity48

Maturing project, gaining track record

 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.

###  Release Activity

Cadence

Every ~64 days

Recently: every ~127 days

Total

9

Last Release

384d ago

Major Versions

1.3.2 → 2.0.02025-04-23

### Community

Maintainers

![](https://www.gravatar.com/avatar/95555999d61957aa18a23d42afe8bcf7aad3a5e6d9dcc8c7e41ba183f405e49e?d=identicon)[iliain](/maintainers/iliain)

---

Top Contributors

[![Iliain](https://avatars.githubusercontent.com/u/2579262?v=4)](https://github.com/Iliain "Iliain (23 commits)")

---

Tags

drag-and-dropdroppableshortcodessilverstripetextareasilverstripecmsshortcodesmodulardragdrop

### Embed Badge

![Health badge](/badges/iliain-silverstripe-droppable/health.svg)

```
[![Health](https://phpackages.com/badges/iliain-silverstripe-droppable/health.svg)](https://phpackages.com/packages/iliain-silverstripe-droppable)
```

###  Alternatives

[silverstripe/cms

The SilverStripe Content Management System

5163.4M1.3k](/packages/silverstripe-cms)

PHPackages © 2026

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