Browse Source

Grid\Column::editable支持一对一关联字段更新

jqh 5 năm trước cách đây
mục cha
commit
9de93b19b2
1 tập tin đã thay đổi với 10 bổ sung2 xóa
  1. 10 2
      src/Grid/Displayers/Editable.php

+ 10 - 2
src/Grid/Displayers/Editable.php

@@ -44,7 +44,7 @@ HTML;
         Admin::style(
             <<<CSS
 .grid-editable{border-bottom:dashed 1px $color;color: $color;display: inline-block}
-.grid-editable+.save{margin-left: 0.55rem;color: $color}
+.grid-editable+.save{margin-left: 0.5rem;color: $color}
 CSS
         );
     }
@@ -72,7 +72,15 @@ $('.{$this->selector}+.save').on("click",function() {
         _token: Dcat.token,
         _method: 'PUT'
     };
-    data[name] = value;
+    if (name.indexOf('.') === -1) {
+        data[name] = value;
+    } else {
+        name = name.split('.');
+        
+        data[name[0]] = {};
+        data[name[0]][name[1]] = value;
+    }
+    
     Dcat.NP.start();
     $.ajax({
         url: url,