Browse Source

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

jqh 5 years ago
parent
commit
9de93b19b2
1 changed files with 10 additions and 2 deletions
  1. 10 2
      src/Grid/Displayers/Editable.php

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

@@ -44,7 +44,7 @@ HTML;
         Admin::style(
         Admin::style(
             <<<CSS
             <<<CSS
 .grid-editable{border-bottom:dashed 1px $color;color: $color;display: inline-block}
 .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
 CSS
         );
         );
     }
     }
@@ -72,7 +72,15 @@ $('.{$this->selector}+.save').on("click",function() {
         _token: Dcat.token,
         _token: Dcat.token,
         _method: 'PUT'
         _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();
     Dcat.NP.start();
     $.ajax({
     $.ajax({
         url: url,
         url: url,