Skip to content
Snippets Groups Projects
form.php 899 B
Newer Older
<?php
/**
 * Created by PhpStorm.
 * User: ep
 * Date: 12/23/15
 * Time: 6:16 PM
 */
Carsten  Rose's avatar
Carsten Rose committed

namespace qfq;
use qfq\exceptions\UserException;
use qfq\exceptions\CodeException;
Carsten  Rose's avatar
Carsten Rose committed
require_once(__DIR__ . '/../qfq/Form.php');
require_once(__DIR__ . '/../exceptions/UserException.php');
require_once(__DIR__ . '/../exceptions/CodeException.php');
//TODO: unit tests fuer alle abgefangenen Exceptions
Carsten  Rose's avatar
Carsten Rose committed
/*
 *
 * @param string $bodytext keyvalue pairs.
 *
 * @return $string LOAD: the form as HTML, SAVE: success or failure message, or JS redirect to destination page.
 */
function renderForm($bodytext = "") {
    try {
        $form = new \qfq\Form();
Carsten  Rose's avatar
Carsten Rose committed
        echo $form->process();

    } catch (UserException $e) {
        echo $e->formatMessage();
    } catch (CodeException $e) {
        echo $e->formatMessage();
    } catch (Exception $e) {
        echo "Generic Exception: " . $e->getMessage();
    }