File tree Expand file tree Collapse file tree 2 files changed +14
-1
lines changed
Expand file tree Collapse file tree 2 files changed +14
-1
lines changed Original file line number Diff line number Diff line change @@ -22,11 +22,15 @@ class Grid extends Field
2222
2323 protected $ min_rows ;
2424
25+ protected $ fields ;
26+
2527 protected $ mode = GridModeOption::Table;
2628
27- public function __construct (string $ handle )
29+ public function __construct (string $ handle, array $ fields = [] )
2830 {
2931 parent ::__construct ($ handle );
32+
33+ $ this ->fields = collect ($ fields );
3034 }
3135
3236 public function fieldToArray (): Collection
@@ -38,6 +42,7 @@ public function fieldToArray(): Collection
3842 'max_rows ' => $ this ->max_rows ,
3943 'min_rows ' => $ this ->min_rows ,
4044 'mode ' => $ this ->mode ->value ,
45+ 'fields ' => $ this ->fieldsToArray (),
4146 ]);
4247 }
4348
Original file line number Diff line number Diff line change 6565
6666 expect ($ field ->toArray ()['field ' ]['mode ' ])->toBe (\Tdwesten \StatamicBuilder \Enums \GridModeOption::Table->value );
6767});
68+
69+ it ('can render to a array with fields ' , function () {
70+ $ field = new \Tdwesten \StatamicBuilder \FieldTypes \Grid ('grid ' , [
71+ new \Tdwesten \StatamicBuilder \FieldTypes \Text ('title ' ),
72+ ]);
73+
74+ expect ($ field ->toArray ()['field ' ]['fields ' ][0 ]['field ' ]['type ' ])->toBe ('text ' );
75+ });
You can’t perform that action at this time.
0 commit comments