/** * Generates HTML output for all fieldsets and their children elements. * * This method is hardly used in the public API. The only reason why this is a public method is to enable * customization through class extension. * * @param Fieldset $objFieldset The Fieldset object to parse * @param string $strSet Previously generated HTML * @param boolean $hideEmpty Set to true to hide empty field values from the overview. Defaults to false. * @return string Generated HTML */ public function fieldsetAsHtml($objFieldset, &$strSet, $hideEmpty = false) { $strTableOutput = ""; foreach ($objFieldset->getFields() as $objField) { if (is_object($objField) && get_class($objField) !== "ValidFormBuilder\\Hidden") { //*** Get the string value. If it's an array, implode with ',' $strValue = $objField->getValue(); if (is_array($strValue)) { $strValue = implode(", ", $strValue); } if (!empty($strValue) && $hideEmpty || !$hideEmpty && !is_null($strValue)) { if ($objField->hasFields()) { switch (get_class($objField)) { case "ValidFormBuilder\\MultiField": $strSet .= $this->multiFieldAsHtml($objField, $hideEmpty); break; default: $strSet .= $this->areaAsHtml($objField, $hideEmpty); } } else { $strSet .= $this->fieldAsHtml($objField, $hideEmpty); } } if ($objField->isDynamic()) { $intDynamicCount = $objField->getDynamicCount(); if ($intDynamicCount > 0) { for ($intCount = 1; $intCount <= $intDynamicCount; $intCount++) { switch (get_class($objField)) { case "ValidFormBuilder\\MultiField": $strSet .= $this->multiFieldAsHtml($objField, $hideEmpty, $intCount); break; case "ValidFormBuilder\\Area": $strSet .= $this->areaAsHtml($objField, $hideEmpty, $intCount); break; default: $strSet .= $this->fieldAsHtml($objField, $hideEmpty, $intCount); } } } } } } $strHeader = $objFieldset->getHeader(); if (!empty($strHeader) && !empty($strSet)) { $strTableOutput .= "<tr>"; $strTableOutput .= "<td colspan=\"3\"> </td>\n"; $strTableOutput .= "</tr>"; $strTableOutput .= "<tr>"; $strTableOutput .= "<td colspan=\"3\"><b>{$strHeader}</b></td>\n"; $strTableOutput .= "</tr>"; } if (!empty($strSet)) { $strTableOutput .= $strSet; } return $strTableOutput; }