Form::setShowSubmit()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 1
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
namespace ntentan\honam\engines\php\helpers\form;
3
4
/**
5
 * The form class. This class represents the overall form class. This form represents the main form for collecting data
6
 * from the user.
7
 */
8
class Form extends Container
9
{
10
    protected $submitValues = array('Submit');
11
    protected $showSubmit = true;
12
    protected $method = "POST";
13
    private $action;
14
15
    public function __construct()
16
    {
17
        $this->action = filter_var($_SERVER["REQUEST_URI"], FILTER_VALIDATE_URL);
18
    }
19
20
    public function setAction($action)
21
    {
22
        $this->action = $action;
23
        return $this;
24
    }
25
    
26
    public function renderHead()
27
    {
28
        $this->setAttribute("method", $this->method);
29
        $this->setAttribute('action', $this->action);
30
        $this->setAttribute('accept-charset', 'utf-8');
31
        
32
        return $this->templateRenderer->render('form_head', ['element' => $this]);
33
    }
34
35
    public function renderFoot()
36
    {
37
        return $this->templateRenderer->render(
38
            'form_foot', ['show_submit' => $this->showSubmit, 'submit_values' => $this->submitValues]
39
        );
40
    }
41
    
42
    public function setShowSubmit($showSubmit)
43
    {
44
        $this->showSubmit = $showSubmit;
45
    }
46
    
47
    public function setSubmitValues($submitValues)
48
    {
49
        $this->submitValues = $submitValues;
50
    }
51
}
52