2
2
3
3
namespace App \Admin \Controllers ;
4
4
5
+ use Encore \Admin \Actions \RowAction ;
5
6
use Encore \Admin \Admin ;
6
7
use Encore \Admin \Grid ;
7
8
use Encore \Admin \Layout \Content ;
@@ -15,7 +16,47 @@ public static function makeEditFormAction(Grid &$grid)
15
16
$ actions ->disableEdit ();
16
17
$ url = Request::capture ()->getPathInfo ();
17
18
Admin::script (<<<EOF
18
- componentEditForm.apply('CEForm',' {$ url }');
19
+ componentForm.make = function () {
20
+ componentForm._clear();
21
+ componentForm._createModal();
22
+ let url = componentForm.url + '/'+this.getAttribute('data-id') + '/edit';
23
+ componentForm._createBox(url);
24
+ }
25
+ componentForm.apply('CEForm',' {$ url }');
26
+ EOF
27
+ );
28
+
29
+ $ actions ->add (new
30
+ class extends RowAction
31
+ {
32
+ public $ name = '修改 ' ;
33
+
34
+ public function render ()
35
+ {
36
+ $ id = $ this ->getKey ();
37
+ return "<a href='javascript:void(0);' class='CEForm' data-id=' $ id', class=> {$ this ->name ()}</a> " ;
38
+ }
39
+ });
40
+ });
41
+ }
42
+
43
+ /**
44
+ * 旧版图标模式
45
+ * @param Grid $grid
46
+ */
47
+ public static function _makeEditFormAction (Grid &$ grid )
48
+ {
49
+ $ grid ->actions (function ($ actions ) {
50
+ $ actions ->disableEdit ();
51
+ $ url = Request::capture ()->getPathInfo ();
52
+ Admin::script (<<<EOF
53
+ componentForm.make = function () {
54
+ componentForm._clear();
55
+ componentForm._createModal();
56
+ let url = componentForm.url + '/'+this.getAttribute('data-id') + '/edit';
57
+ componentForm._createBox(url);
58
+ }
59
+ componentForm.apply('CEForm',' {$ url }');
19
60
EOF
20
61
);
21
62
$ id = $ actions ->getKey ();
0 commit comments