@@ -170,6 +170,11 @@ class MultiColumnWizard extends Widget
170
170
171
171
private ?TranslatorInterface $ translator = null ;
172
172
173
+ /**
174
+ * @var array|mixed|string|string[]|null
175
+ */
176
+ private mixed $ defaultValue ;
177
+
173
178
/**
174
179
* Initialize the object
175
180
*
@@ -257,6 +262,10 @@ public function __set($strKey, $varValue)
257
262
}
258
263
break ;
259
264
265
+ case 'default ' :
266
+ $ this ->defaultValue = StringUtil::deserialize ($ varValue , true );
267
+ break ;
268
+
260
269
case 'mandatory ' :
261
270
$ this ->arrConfiguration ['mandatory ' ] = $ varValue ? true : false ;
262
271
break ;
@@ -804,6 +813,10 @@ public function generate($overwriteRowCurrentRow = null, $onlyRows = false)
804
813
}
805
814
806
815
$ intNumberOfRows = max (count ($ this ->varValue ), 1 );
816
+ $ useDefaultValue = (0 == count ($ this ->varValue ));
817
+ if ($ useDefaultValue && !empty ($ this ->defaultValue )) {
818
+ $ intNumberOfRows = count ($ this ->defaultValue );
819
+ }
807
820
808
821
// always show the minimum number of rows if set
809
822
if ($ this ->minCount && ($ intNumberOfRows < $ this ->minCount )) {
@@ -839,6 +852,11 @@ public function generate($overwriteRowCurrentRow = null, $onlyRows = false)
839
852
$ arrField = array_merge ($ arrField , $ this ->arrRowSpecificData [$ i ][$ strKey ]);
840
853
}
841
854
855
+ // Should we do this above the foreach and run a foreach twice ... nope.
856
+ if ($ useDefaultValue && !empty ($ this ->defaultValue [$ i ][$ strKey ] ?? null )) {
857
+ $ this ->varValue [$ i ][$ strKey ] = $ this ->defaultValue [$ i ][$ strKey ];
858
+ }
859
+
842
860
$ objWidget = $ this ->initializeWidget (
843
861
$ arrField ,
844
862
$ i ,
0 commit comments