@@ -518,11 +518,19 @@ protected function validator($varInput)
518518 }
519519 unset($ arrSubField );
520520
521+ // Clean all unset keys.
522+ foreach (\array_keys ($ varInput ) as $ fieldName ) {
523+ if (!\array_key_exists ($ fieldName , $ this ->arrSubFields )) {
524+ unset($ varInput [$ fieldName ]);
525+ }
526+ }
527+
521528 if ($ blnHasError ) {
522529 $ this ->blnSubmitInput = false ;
523530 $ this ->addError ($ GLOBALS ['TL_LANG ' ]['ERR ' ]['general ' ]);
524531 }
525- return $ varInput ;
532+
533+ return $ varInput ?: null ;
526534 }
527535
528536 /**
@@ -606,22 +614,28 @@ public function generate()
606614 . '</p></td> ' ;
607615 }
608616
609- $ strHead = '' ;
610- $ strBody = sprintf ('<tbody><tr>%s</tr></tbody> ' , implode ("</tr> \n<tr> " , $ arrOptions ));
611-
612- $ strOutput = sprintf (
613- '<table%s id="ctrl_%s" class="tl_subdca">%s%s</table> ' ,
614- (($ this ->style ) ? ('style=" ' . $ this ->style . '" ' ) : ('' )),
615- $ this ->strId ,
616- $ strHead ,
617- $ strBody
618- );
619-
620- return sprintf (
621- '<div id="ctrl_%s" class="tl_multiwidget_container%s clr">%s</div> ' ,
622- $ this ->strName ,
623- (strlen ($ this ->strClass ) ? ' ' . $ this ->strClass : '' ),
624- $ strOutput
625- );
617+ $ class = ($ this ->strClass !== '' ? ' ' . $ this ->strClass : '' );
618+ $ style = (($ this ->style ) ? ('style=" ' . $ this ->style . '" ' ) : ('' ));
619+ $ options = implode ("</tr> \n<tr> " , $ arrOptions );
620+
621+ return <<<EOF
622+ <div
623+ id="ctrl_ {$ this ->strName }"
624+ class="tl_multiwidget_container {$ class } clr"
625+ >
626+ <input type="hidden" name=" {$ this ->strName }[]" value="">
627+ <table
628+ $ style
629+ id="ctrl_ {$ this ->strId }"
630+ class="tl_subdca"
631+ >
632+ <tbody>
633+ <tr>
634+ $ options
635+ </tr>
636+ </tbody>
637+ </table>
638+ </div>
639+ EOF ;
626640 }
627641}
0 commit comments