jqh 5 年之前
父節點
當前提交
839d6b7d1c
共有 1 個文件被更改,包括 11 次插入3 次删除
  1. 11 3
      src/Grid/Displayers/Modal.php

+ 11 - 3
src/Grid/Displayers/Modal.php

@@ -6,6 +6,13 @@ use Dcat\Admin\Support\Helper;
 
 
 class Modal extends AbstractDisplayer
 class Modal extends AbstractDisplayer
 {
 {
+    protected $title;
+
+    public function title(string $title)
+    {
+        $this->title = $title;
+    }
+
     public function display($callback = null)
     public function display($callback = null)
     {
     {
         $title = $this->trans('title');
         $title = $this->trans('title');
@@ -15,11 +22,12 @@ class Modal extends AbstractDisplayer
 
 
         $html = $this->value;
         $html = $this->value;
         if ($callback instanceof \Closure) {
         if ($callback instanceof \Closure) {
-            $callback = $callback->bindTo($this->row);
-
-            $html = Helper::render($callback($this));
+            $html = Helper::render(
+                $callback->call($this->row, $this)
+            );
         }
         }
 
 
+        $title = $this->title ?: $title;
         $key = $this->grid->getName().$this->key();
         $key = $this->grid->getName().$this->key();
 
 
         return <<<EOT
         return <<<EOT