123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051 |
- <?php
- namespace App\Admin\Extensions\Tools;
- use Encore\Admin\Grid\Tools\AbstractTool;
- use Encore\Admin\Widgets\Form;
- class DialogTool extends AbstractTool
- {
-
- protected $config;
- public function __construct($widget, $config = array(), $buttonName = '按钮')
- {
- if (empty($config)) {
- $config = array(
- 'button' => $buttonName,
- 'title' => "提示",
- 'dialog_cancel' => "取消",
- 'dialog_ok' => "确认",
- 'is_batch' => true
- );
- }
- $this->config=$config;
- $this->config['uniqid']=uniqid();
- if ($widget instanceof Form) {
- $widget->attribute('id', 'dialog-form-'.$this->config['uniqid']);
- $widget->disableReset();
- $widget->disableSubmit();
- $this->config['is_form']=true;
- } else {
- $this->config['is_form']=false;
- }
- $this->config['form']=$widget->render();
- }
- public function render()
- {
- return view('admin.tools.dialog', $this->config);
- }
- }
|