File tree Expand file tree Collapse file tree 1 file changed +13
-0
lines changed
Expand file tree Collapse file tree 1 file changed +13
-0
lines changed Original file line number Diff line number Diff line change @@ -39,8 +39,11 @@ final class ArrayArrayFactory extends AbstractConcreteFormArrayFactory {
3939
4040 /**
4141 * {@inheritDoc}
42+ *
43+ * phpcs:disable Generic.Metrics.CyclomaticComplexity.TooHigh
4244 */
4345 public function createFormArray (
46+ // phpcs:enable
4447 DefinitionInterface $ definition ,
4548 FormStateInterface $ formState ,
4649 FormArrayFactoryInterface $ formArrayFactory
@@ -85,6 +88,16 @@ public function createFormArray(
8588 );
8689
8790 if (0 === $ numItems ) {
91+ if (0 !== $ definition ->getMaxItems ()) {
92+ // There might be a file field in the child elements. To ensure that the
93+ // form is sent as multipart/form-data in case a file field is
94+ // dynamically added, we claim that the form has a file element.
95+ // If there's no file field initially, the form would be sent as
96+ // application/x-www-form-urlencoded, i.e. file contents wouldn't be
97+ // submitted.
98+ $ formState ->setHasFileElement (TRUE );
99+ }
100+
88101 // Ensure we get an empty array if there's no item.
89102 $ form [] = [
90103 '#type ' => 'hidden ' ,
You can’t perform that action at this time.
0 commit comments