bigfork/silverstripe-textdropdowndropdownfield

A text field combined with two dropdown fields.

Installs: 1

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Watchers: 0

Forks: 0

Open Issues: 0

Language:JavaScript

Type:silverstripe-vendormodule

1.0.0 2025-07-16 14:58 UTC

This package is auto-updated.

Last update: 2025-07-16 14:59:25 UTC


README

This is a Bigfork-maintained fork of a fork of adrhumphreys/silverstripe-textdropdownfield and so contains opinionated changes.

This version has two dropdowns instead of one. For twice the dropdown-ness.

Text dropdown dropdown field

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

Requirements

  • PHP ^7.4 || ^8.0
  • SilverStripe ^4.0 || ^5

Installation

composer require bigfork/silverstripe-textdropdowndropdownfield

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\TextDropdownDropdownField\TextDropdownDropdownField;
use SilverStripe\ORM\DataObject;

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

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

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

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

        return $fields;
    }
}

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

Maintainers

  • Bigfork