Dead simple modals for SilverStripe (works in the admin too!)

Fund package maintenance!

Installs: 3 954

Dependents: 0

Suggesters: 0

Security: 0

Stars: 8

Watchers: 5

Forks: 2

Open Issues: 1


1.2.0 2023-07-28 14:38 UTC

This package is auto-updated.

Last update: 2024-02-09 13:18:09 UTC


Build Status scrutinizer Code coverage


Dead simple modals for SilverStripe (works in the admin too!)

Sample usage

Simply pass the content to display in the modal. The modal will be accessible through a button in the fieldset

You can also set an iframe to be displayed within the modal in case you want to display a form for example.

$myHtmlContent = "<p>Some content here</p>";
$ImportStuff = new PureModal('ImportStuff', 'Import Stuff', $myHtmlContent);
$fields->addFieldToTab('Root.Stuff', $ImportStuff);

And here is a sample import_stuff method

public function import_stuff(HTTPRequest $req)
    $Stuff = $this->getRequestedRecord();
    $fields = new FieldList([
        new FileField('File'),
        new HiddenField('StuffID', null, $Stuff->ID),
    $actions = new FieldList([
        new FormAction('doUpload', 'Upload')
    $form = new Form(Controller::curr(), 'MyForm', $fields, $actions);

    return PureModal::renderDialog($this, ['Form' => $form]);

Modal action

This feature require my cms-actions module.

    public function getCMSActions()
        $actions = parent::getCMSActions();
        $doDeny = new PureModalAction("doDeny", "Deny");
        $predefinedText = <<<TEXT
Dear Customer,

Your request has been denied.

Best regards,
        $iframeFields = new FieldList([
            new DropdownField("SelectReason", "Select reason"),
            new TextareaField("EnterText", "Enter custom text", $predefinedText),
        $doDeny->setDialogButtonTitle('Deny the request'); // customised modal submit button

It creates a button that opens a modal with a set of fields. These fields are submitted alongside the form.

    public function doDeny($data)
        $this->DeniedReason = $data['EnterText'];
        $this->Status = "denied";
        return 'Denied';

You can remove the submit button from the modal itself, for example to make it an information window only. By doing like this:

    public function getCMSActions()
        $actions = parent::getCMSActions();
        $doDeny = new PureModalAction("noopInfo", "Information");

        // .. add fields



Tested with ^5


LeKoala - thomas@lekoala.be