function renderElement(&$element, $required, $error) { $blockName = $this->_matchBlock($element); // are we inside a group? if ('qf_main_loop' != $this->_tpl->currentBlock) { if (0 != $this->_groupElementIdx && $this->_tpl->placeholderExists('qf_separator', $blockName)) { if (is_array($this->_groupSeparator)) { $this->_tpl->setVariable('qf_separator', $this->_groupSeparator[($this->_groupElementIdx - 1) % count($this->_groupSeparator)]); } else { $this->_tpl->setVariable('qf_separator', (string)$this->_groupSeparator); } } $this->_groupElementIdx++; } elseif(!empty($error)) { // show the error message or keep it for later use if ($this->_tpl->blockExists($blockName . '_error')) { $this->_tpl->setVariable('qf_error', $error); } else { $this->_errors[] = $error; } } // show an '*' near the required element if ($required) { $this->_showRequired = true; if ($this->_tpl->blockExists($blockName . '_required')) { $this->_tpl->touchBlock($blockName . '_required'); } } // Prepare multiple labels $labels = $element->getLabel(); if (is_array($labels)) { $mainLabel = array_shift($labels); } else { $mainLabel = $labels; } // render the element itself with its main label $this->_tpl->setVariable('qf_element', $element->toHtml()); if ($this->_tpl->placeholderExists('qf_label', $blockName)) { $this->_tpl->setVariable('qf_label', $mainLabel); } // render extra labels, if any if (is_array($labels)) { foreach($labels as $key => $label) { $key = is_int($key)? $key + 2: $key; if ($this->_tpl->blockExists($blockName . '_label_' . $key)) { $this->_tpl->setVariable('qf_label_' . $key, $label); } } } $this->_tpl->parse($blockName); $this->_tpl->parseCurrentBlock(); }