<?php namespace App\Distributor\Actions; use App\Distributor\Forms\ImportProduct; use Dcat\Admin\Grid\Tools\AbstractTool; use Dcat\Admin\Widgets\Modal; use App\Distributor\Forms\SmmAddAccount as SmmAddAccountForm; class SmmAddAccount extends AbstractTool { protected $style = 'btn btn-primary'; protected $title = 'add_platform_account'; public function title() { return '<i class="feather icon-user-plus"></i> '.admin_trans('admin.add_platform_account'); } public function render() { // 实例化表单类 $form = SmmAddAccountForm::make(); return Modal::make() ->lg() ->title(admin_trans_label($this->title)) ->body($form) // 因为此处使用了表单异步加载功能,所以一定要用 onLoad 方法 // 如果是非异步方式加载表单,则需要改成 onShow 方法 ->button($this->getButtonHTML()); } protected function getButtonHTML() { $title= $this->title(); return <<<HTML <button class="btn btn-success"> <i class="feather"></i> {$title} </button> HTML; } }