承接 lekoala/silverstripe-pure-modal 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

lekoala/silverstripe-pure-modal

最新稳定版本:2.0.0

Composer 安装命令:

composer require lekoala/silverstripe-pure-modal

包简介

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

README 文档

README

Build Status scrutinizer Code coverage

Intro

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);
$ImportStuff->setIframeAction('import_stuff');
$ImportStuff->setIframeTop(true);

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,
TEXT;
        $iframeFields = new FieldList([
            new DropdownField("SelectReason", "Select reason"),
            new TextareaField("EnterText", "Enter custom text", $predefinedText),
        ]);
        $doDeny->setFieldList($iframeFields);
        $doDeny->setShouldRefresh(true);
        $doDeny->setDialogButtonTitle('Deny the request'); // customised modal submit button
        $actions->push($doDeny);
    }

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";
        $this->write();
        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

        $doDeny->setShowDialogButton(false);
        $actions->push($doDeny);
    }

Compatibility

Tested with ^5

Maintainer

LeKoala - thomas@lekoala.be

统计信息

  • 总下载量: 10.93k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 9
  • 点击次数: 1
  • 依赖项目数: 1
  • 推荐数: 0

GitHub 信息

  • Stars: 9
  • Watchers: 3
  • Forks: 3
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2021-06-24