FormBuildPlain.php 1.41 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
<?php

namespace qfq;

use qfq;

require_once(__DIR__ . '/../qfq/store/Store.php');
require_once(__DIR__ . '/../qfq/Constants.php');
require_once(__DIR__ . '/../qfq/exceptions/DbException.php');
require_once(__DIR__ . '/../qfq/Database.php');

/**
 * Created by PhpStorm.
 * User: crose
 * Date: 1/6/16
 * Time: 8:02 PM
 */
class FormBuildPlain {
    protected $formDef = array();  // copy of the loaded form
    protected $feDefAction = array(); // copy of all formElement.class='action' of the loaded form
    protected $feDefNative = array(); // copy of all formElement.class='native' of the loaded form
    protected $store = null;

    public function __construct(array $formDef, array $feDefAction, array $feDefNative) {
        $this->formDef = $formDef;
        $this->feDefAction = $feDefAction;
        $this->feDefNative = $feDefNative;
        $this->store = \qfq\store\Store::getInstance();
        $this->db = new Database();
    }


    public function head() {
        $html = '<h1>' . $this->formDef['title'] . '</h1><form action="?" method="post" target="_top" accept-charset="UTF-8">';

        return $html;
    }

    public function tail() {
        $html = '<input type="submit" value="Submit"></form>';

        return $html;
    }

    public function elements() {
        $html = '';

        foreach ($this->feDefNative as $fe) {
            $html .= $fe['name'] . '<br>';
        }
        return $html;
    }

}