@@ -10,18 +10,22 @@ class Linear extends DLPField
1010 public function render ()
1111 {
1212 $ id = $ this ->formatName ($ this ->id );
13- if (isset ($ this ->columns )){
13+ if (isset ($ this ->columns )) {
1414 $ columns = json_encode ($ this ->columns );
15- }else {
15+ } else {
1616 $ 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 ' ];
1923 }
2024 $ columns = json_encode ($ columns );
2125 }
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 ]);
2529 $ data = json_encode ($ this ->options , JSON_UNESCAPED_UNICODE | JSON_HEX_QUOT | JSON_HEX_APOS );
2630 $ this ->script = <<<EOT
2731new ComponentLine(" {$ id }",JSON.parse(' {$ columns }'),JSON.parse(' {$ data }'),JSON.parse(' {$ options }'));
0 commit comments