@@ -10,18 +10,22 @@ class Linear extends DLPField
10
10
public function render ()
11
11
{
12
12
$ id = $ this ->formatName ($ this ->id );
13
- if (isset ($ this ->columns )){
13
+ if (isset ($ this ->columns )) {
14
14
$ columns = json_encode ($ this ->columns );
15
- }else {
15
+ } else {
16
16
$ columns = [];
17
- foreach (array_keys (current ($ this ->options )) as $ key ){
18
- $ columns [$ key ] = ['name ' =>$ key ,'type ' => 'text ' ];
17
+ $ record = current ($ this ->options );
18
+ if (!is_array ($ record ) || empty ($ record )) {
19
+ return ;
20
+ }
21
+ foreach (array_keys ($ record ) as $ key ) {
22
+ $ columns [$ key ] = ['name ' => $ key , 'type ' => 'text ' ];
19
23
}
20
24
$ columns = json_encode ($ columns );
21
25
}
22
- $ options = isset ($ this ->attributes ['options ' ]) ? json_encode ($ this ->attributes ['options ' ]) : json_encode (['sortable ' => true ,'delete ' => true ]);
23
- $ height = isset ($ this ->attributes ['height ' ]) ? $ this ->attributes ['height ' ] : '360px ' ;
24
- $ this ->addVariables (['height ' => $ height ]);
26
+ $ options = isset ($ this ->attributes ['options ' ]) ? json_encode ($ this ->attributes ['options ' ]) : json_encode (['sortable ' => true , 'delete ' => true ]);
27
+ $ height = isset ($ this ->attributes ['height ' ]) ? $ this ->attributes ['height ' ] : '360px ' ;
28
+ $ this ->addVariables (['height ' => $ height ]);
25
29
$ data = json_encode ($ this ->options , JSON_UNESCAPED_UNICODE | JSON_HEX_QUOT | JSON_HEX_APOS );
26
30
$ this ->script = <<<EOT
27
31
new ComponentLine(" {$ id }",JSON.parse(' {$ columns }'),JSON.parse(' {$ data }'),JSON.parse(' {$ options }'));
0 commit comments