/** * Add multifield * * See {@link \ValidFormBuilder\ValidForm::addMultiField()} * * @see \ValidFormBuilder\ValidForm::addMultiField() */ public function addMultiField($label = null, $meta = array()) { $objField = new MultiField($label, $meta); $objField->setRequiredStyle($this->__requiredstyle); // *** Page already defined? $objPage = $this->__elements->getLast("ValidFormBuilder\\Page"); if ($this->__elements->count() == 0 || !is_object($objPage)) { $objPage = $this->addPage(); } // *** Fieldset already defined? $objFieldset = $objPage->getElements()->getLast("ValidFormBuilder\\Fieldset"); if ($this->__elements->count() == 0 || !is_object($objFieldset)) { $objFieldset = $this->addFieldset(); } $objField->setMeta("parent", $objFieldset, true); // *** Add field to the fieldset. $objFieldset->addField($objField); return $objField; }
/** * Add a multifield to the Area * * @param string $label The multifield's label * @param array $meta The standard meta array * @return \ValidFormBuilder\MultiField */ public function addMultiField($label = null, $meta = array()) { if (!array_key_exists("dynamic", $meta)) { $meta["dynamic"] = $this->__dynamic; } // *** Overwrite dynamic settings. We cannot have a dynamic multifield inside a dynamic area. if ($this->__dynamic) { $meta["dynamic"] = $this->__dynamic; $meta["dynamicLabel"] = ""; } $objField = new MultiField($label, $meta); $objField->setRequiredStyle($this->__requiredstyle); $objField->setMeta("parent", $this, true); $this->__fields->addObject($objField); return $objField; }
/** * Generates HTML output for the given MultiField object and its child elements * * @internal * @param MultiField $objField The Area object to parse * @param boolean $hideEmpty Set to true to hide empty field values from the overview. Defaults to false. * @param integer $intDynamicCount The dynamic counter for the current MultiField being parsed * @return string Generated HTML */ private function multiFieldAsHtml($objField, $hideEmpty = false, $intDynamicCount = 0) { $strReturn = ""; if ($objField->hasContent($intDynamicCount)) { if ($objField->hasFields()) { $strValue = ""; $objSubFields = $objField->getFields(); $intCount = 0; foreach ($objSubFields as $objSubField) { $intCount++; if (get_class($objSubField) == "ValidFormBuilder\\Hidden" && $objSubField->isDynamicCounter()) { continue; } $varValue = $objSubField->getValue($intDynamicCount); $strValue .= is_array($varValue) ? implode(", ", $varValue) : $varValue; $strValue .= $objSubFields->count() > $intCount ? " " : ""; } $strValue = trim($strValue); $strLabel = $objField->getShortLabel(); if (!empty($strValue) && $hideEmpty || !$hideEmpty && !empty($strValue)) { $strValue = nl2br($strValue); $strValue = htmlspecialchars($strValue, ENT_QUOTES); $strReturn .= "<tr class=\"vf__field_value\">"; $strReturn .= "<td valign=\"top\" " . ($strReturn .= "style=\"white-space:nowrap; padding-right: 20px\" " . ($strReturn .= "class=\"vf__field\">" . ($strReturn .= $strLabel . ($strReturn .= "</td>" . ($strReturn .= "<td valign=\"top\" class=\"vf__value\">" . ($strReturn .= "<strong>" . $strValue . "</strong>" . ($strReturn .= "</td>\n"))))))); $strReturn .= "</tr>"; } } } return $strReturn; }