Test Failed
Push — master ( b5485e...f1bbc8 )
by Gabor
06:06
created

ApplicationEditForm::initAdapter()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
/**
3
 * WebHemi.
4
 *
5
 * PHP version 7.1
6
 *
7
 * @copyright 2012 - 2017 Gixx-web (http://www.gixx-web.com)
8
 * @license   https://opensource.org/licenses/MIT The MIT License (MIT)
9
 *
10
 * @link      http://www.gixx-web.com
11
 */
12
declare(strict_types = 1);
13
14
namespace WebHemi\Form\Preset;
15
16
use WebHemi\Form\Element\Html\HtmlElement;
17
18
/**
19
 * Class ApplicationEditForm
20
 */
21
class ApplicationEditForm extends AbstractPreset
22
{
23
    /**
24
     * Initialize the adapter
25
     */
26
    protected function initAdapter()
27
    {
28
        $this->formAdapter->initialize('application', '[URL]/save', 'POST');
29
    }
30
31
    /**
32
     * Initialize and add elements to the form.
33
     *
34
     * @return void
35
     *
36
     * @codeCoverageIgnore - only composes an object.
37
     */
38
    protected function init() : void
39
    {
40
        $this->initAdapter();
41
42
        $name = $this->createElement(
43
            HtmlElement::class,
44
            HtmlElement::HTML_ELEMENT_INPUT_TEXT,
45
            'name',
46
            'Application name'
47
        );
48
49
        $title = $this->createElement(
50
            HtmlElement::class,
51
            HtmlElement::HTML_ELEMENT_INPUT_TEXT,
52
            'title',
53
            'Display name (title)'
54
        );
55
56
        $description = $this->createElement(
57
            HtmlElement::class,
58
            HtmlElement::HTML_ELEMENT_TEXTAREA,
59
            'description',
60
            'Description'
61
        );
62
63
        $enabled = $this->createElement(
64
            HtmlElement::class,
65
            HtmlElement::HTML_ELEMENT_INPUT_CHECKBOX,
66
            'is_enabled',
67
            'Activated ?'
68
        );
69
70
        $submit = $this->createElement(
71
            HtmlElement::class,
72
            HtmlElement::HTML_ELEMENT_SUBMIT,
73
            'submit',
74
            'Save'
75
        );
76
77
        $this->formAdapter->addElement($name)
78
            ->addElement($title)
79
            ->addElement($description)
80
            ->addElement($enabled)
81
            ->addElement($submit);
82
    }
83
}
84