adrhumphreys/silverstripe-textdropdownfield

A text field combined with a dropdown field.

Maintainers

👁 adrhumphreys

Package info

github.com/adrhumphreys/silverstripe-textdropdownfield

Language:JavaScript

Type:silverstripe-vendormodule

pkg:composer/adrhumphreys/silverstripe-textdropdownfield

Statistics

Installs: 6 382

Dependents: 0

Suggesters: 1

Stars: 10

Open Issues: 1

2.0.0 2025-11-22 22:39 UTC

Requires

Requires (Dev)

Suggests

None

Provides

None

Conflicts

None

Replaces

None

BSD-3-Clause 3bddd7e6b9f1a3ae14790b75af69f01e8f2b336e

cmssilverstripefield

This package is auto-updated.

Last update: 2026-06-04 22:36:13 UTC


README

This lets you add field that is a combination of a dropdown and a text field 👁 Image

Requirements

  • PHP ^8.3
  • SilverStripe ^6

Installation

composer require adrhumphreys/silverstripe-textdropdownfield dev-master

Documentation

When using this field you'll need to specify the name of the field, the title for the field, the text relation, the dropdown relation followed by the dropdown source.

An example usecase could look like this:

<?php
declare(strict_types=1);

use AdrHumphreys\TextDropdownField\TextDropdownField;
use SilverStripe\ORM\DataObject;

class Example extends DataObject
{
 /**
 * @var string[]
 */
 private static $db = [
 'TextContent' => 'Varchar(20)',
 'DropdownContent' => 'Varchar(20)',
 ];

 public function getCMSFields()
 {
 $fields = parent::getCMSFields();

 $source = [
 'p' => 'Paragraph',
 'h1' => 'Header 1',
 'h2' => 'Header 2',
 ];

 $fields->addFieldToTab(
 'Root.Main',
 TextDropdownField::create(
 'NameThatDoesntMatter',
 'Title',
 'TextContent',
 'DropdownContent',
 $source
 ));

 return $fields;
 }
}

If you want to specifically edit the dropdown or text field you can access those through getTextField and getDropdownField on the field after it's been created

Maintainers

Development and contribution

Smash that PR button 🥰