diff --git a/src/Widgets/SubDcaWidget.php b/src/Widgets/SubDcaWidget.php index 12148dcb3..fac21f6ac 100644 --- a/src/Widgets/SubDcaWidget.php +++ b/src/Widgets/SubDcaWidget.php @@ -518,11 +518,19 @@ protected function validator($varInput) } unset($arrSubField); + // Clean all unset keys. + foreach (\array_keys($varInput) as $fieldName) { + if (!\array_key_exists($fieldName, $this->arrSubFields)) { + unset($varInput[$fieldName]); + } + } + if ($blnHasError) { $this->blnSubmitInput = false; $this->addError($GLOBALS['TL_LANG']['ERR']['general']); } - return $varInput; + + return $varInput ?: null; } /** @@ -606,22 +614,28 @@ public function generate() . '

'; } - $strHead = ''; - $strBody = sprintf('%s', implode("\n", $arrOptions)); - - $strOutput = sprintf( - '%s%s', - (($this->style) ? ('style="' . $this->style . '"') : ('')), - $this->strId, - $strHead, - $strBody - ); - - return sprintf( - '
%s
', - $this->strName, - (strlen($this->strClass) ? ' ' . $this->strClass : ''), - $strOutput - ); + $class = ($this->strClass !== '' ? ' ' . $this->strClass : ''); + $style = (($this->style) ? ('style="' . $this->style . '"') : ('')); + $options = implode("\n", $arrOptions); + + return << + + + + + $options + + +
+ + EOF; } }