Explorar o código

grid displayer link

Jiang qinghua %!s(int64=6) %!d(string=hai) anos
pai
achega
4f8a10aba7
Modificáronse 1 ficheiros con 10 adicións e 1 borrados
  1. 10 1
      src/Grid/Displayers/Link.php

+ 10 - 1
src/Grid/Displayers/Link.php

@@ -6,8 +6,17 @@ class Link extends AbstractDisplayer
 {
     public function display($href = '', $target = '_blank')
     {
-        $href = $href ?: $this->value;
+        if ($href instanceof \Closure) {
+            $href = $href->bindTo($this->row);
+
+            $href = call_user_func($href, $this->value);
+
+        } else {
+            $href = $href ?: $this->value;
+
+        }
 
         return "<a href='$href' target='$target'>{$this->value}</a>";
     }
+    
 }