Example #1
0
 public function getHTML()
 {
     $html = '<form method="' . $this->method . '"';
     if (null != $this->action) {
         $html .= ' action="' . $this->action . '"';
     }
     $html .= '>';
     $table = new Table();
     $errorTable = new Table();
     foreach ($this->elements as $element) {
         $description = $this->elementDescriptions[$element->getName()];
         $fieldRow = '<label>' . $description . '</label><br />' . $element->getHTML();
         if ($element instanceof Validatable) {
             if ($this->errors[$element->getName()]) {
                 $errorTable->addRow(array($description . ' ' . $element->getError()));
                 if ($this->errorsUnderFields) {
                     $fieldRow .= '<div class="form_error">Dit ' . $element->getError() . '</div>';
                 }
             }
         }
         $table->addRow(array($fieldRow));
     }
     $buttonRow = array();
     if (true == $this->showSubmitBtn) {
         $btnSubmit = new Button($this->submitBtnName, $this->submitBtnValue);
         $buttonRow[] = $btnSubmit->getHTML();
     }
     if (0 < count($buttonRow)) {
         $table->addRow($buttonRow);
     }
     $html .= $table->getHTML();
     $html .= "\n";
     $html .= '</form>';
     return $html;
 }