* @return string HTML
*/
protected function formatSection( array $fieldsHtml, $sectionName, $anyFieldHasLabel ) {
+ if ( !$fieldsHtml ) {
+ // Do not generate any wrappers for empty sections. Sections may be empty if they only have
+ // subsections, but no fields. A legend will still be added in wrapFieldSetSection().
+ return '';
+ }
+
$displayFormat = $this->getDisplayFormat();
$html = implode( '', $fieldsHtml );
* @return string HTML
*/
protected function formatSection( array $fieldsHtml, $sectionName, $anyFieldHasLabel ) {
+ if ( !$fieldsHtml ) {
+ // Do not generate any wrappers for empty sections. Sections may be empty if they only have
+ // subsections, but no fields. A legend will still be added in wrapFieldSetSection().
+ return '';
+ }
+
$config = [
'items' => $fieldsHtml,
];