My form class, as well as my Fieldset class, has a variable called $child_elements, which is an array of objects. In case of the Form class, these are instances of the Fieldset class and for the Fieldset class these are instances of the Input class.
Every class inherits the function printMarkup() (see below) from the base class. In this function, the object called (e.g. Form), calls the same function for all the objects in $child_elements. This however doesn't work; an empty string is returned instead of markup.
I haven't got a clue to as what I'm doing wrong. Anyone an idea?
Code: Select all
public function printMarkup() {
$this->markupOutput .= "<$this->tagName";
$this->markupOutput .= $this->getAttributes();
$this->markupOutput .= '>'."\n";
if (isset($this->legend)) $this->markupOutput .= '<legend>'.$this->legend.'</legend>'."\n";
for ($i=0; $i<$count($this->child_elements); $i++) {
$elementObj = $this->child_elements[$i];
$elementObjMarkup = $elementObj->printMarkup();
$this->markupOutput .= $elementObjMarkup;
}
$this->markupOutput .= "</$this->tagName>\n\n";
return $this->markupOutput;
}