/** * Invoked at the end of a visit * * @param \r8\Form $form The form being visited * @return Mixed Returns whatever value should be the result of the visit */ public function end(\r8\Form $form) { $hidden = $form->getHiddenHTML(); $result = "{$form}\n" . (!empty($hidden) ? " {$hidden}\n" : "") . " <table class='form-table'>\n"; if (!empty($this->title)) { $result .= " <tr class='form-title'>\n" . " <th colspan='2'>" . htmlspecialchars($this->title) . "</th>\n" . " </tr>\n"; } if ($this->showErrors && !$form->isFormValid()) { $errors = $this->getErrors($form->validateForm()); $result .= " <tr class='form-errors'>\n" . " <td colspan='2'>{$errors}</th>\n" . " </tr>\n"; } $result .= $this->fields . " <tr class='form-submit'>\n" . " <td colspan='2'>" . "<input type='submit' value='" . htmlspecialchars($this->submit) . "' />" . "</td>\n" . " </tr>\n" . " </table>\n" . "</form>\n"; return new \r8\Template\Raw($result); }
/** * Invoked at the end of a visit * * @param \r8\Form $form The form being visited * @return Mixed Returns whatever value should be the result of the visit */ public function end(\r8\Form $form) { $formTpl = clone $this->formTpl; $formTpl->set("form", $form->__toString()); $formTpl->set("hidden", $form->getHiddenHTML()); $formTpl->set("fields", $this->fields); $formTpl->set("isValid", $form->isValid()); $formTpl->set("isFormValid", $form->isFormValid()); $formTpl->set("showErrors", $this->showErrors); $formTpl->set("errors", $this->getErrorTpl($form->validateForm())); return $formTpl; }