Completed
Push — master ( d67f41...79042b )
by Adam
07:27
created

ContactFormBuilder::buildForm()   A

Complexity

Conditions 1
Paths 1

Duplication

Lines 0
Ratio 0 %

Size

Total Lines 48
Code Lines 31

Importance

Changes 0
Metric Value
dl 0
loc 48
rs 9.125
c 0
b 0
f 0
cc 1
eloc 31
nc 1
nop 1
1
<?php
2
/*
3
 * WellCommerce Open-Source E-Commerce Platform
4
 *
5
 * This file is part of the WellCommerce package.
6
 *
7
 * (c) Adam Piotrowski <[email protected]>
8
 *
9
 * For the full copyright and license information,
10
 * please view the LICENSE file that was distributed with this source code.
11
 */
12
13
namespace WellCommerce\Bundle\CmsBundle\Form\Front;
14
15
use WellCommerce\Bundle\CoreBundle\Form\AbstractFormBuilder;
16
use WellCommerce\Component\Form\Elements\FormInterface;
17
18
/**
19
 * Class ContactFormBuilder
20
 *
21
 * @author  Adam Piotrowski <[email protected]>
22
 */
23
class ContactFormBuilder extends AbstractFormBuilder
24
{
25
    public function getAlias(): string
26
    {
27
        return 'front.contact';
28
    }
29
    
30
    public function buildForm(FormInterface $form)
31
    {
32
        $form->addChild($this->getElement('text_field', [
33
            'name'  => 'name',
34
            'label' => 'contact_ticket.label.name',
35
        ]));
36
        
37
        $form->addChild($this->getElement('text_field', [
38
            'name'  => 'surname',
39
            'label' => 'contact_ticket.label.surname',
40
        ]));
41
        
42
        $form->addChild($this->getElement('text_field', [
43
            'name'  => 'phone',
44
            'label' => 'contact_ticket.label.phone_number',
45
        ]));
46
        
47
        $form->addChild($this->getElement('text_field', [
48
            'name'  => 'email',
49
            'label' => 'contact_ticket.label.email',
50
        ]));
51
        
52
        $form->addChild($this->getElement('select', [
53
            'name'        => 'contact',
54
            'label'       => 'contact_ticket.label.contact',
55
            'options'     => $this->get('contact.dataset.front')->getResult('select', [], [
56
                'default_option' => '---',
57
                'label_column'   => 'topic',
58
            ]),
59
            'transformer' => $this->getRepositoryTransformer('entity', $this->get('contact.repository')),
60
        ]));
61
        
62
        $form->addChild($this->getElement('text_field', [
63
            'name'  => 'subject',
64
            'label' => 'contact_ticket.label.subject',
65
        ]));
66
        
67
        $form->addChild($this->getElement('text_area', [
68
            'name'  => 'content',
69
            'label' => 'contact_ticket.label.content',
70
            'rows'  => 5,
71
            'cols'  => 20,
72
        ]));
73
        
74
        $form->addFilter($this->getFilter('no_code'));
75
        $form->addFilter($this->getFilter('trim'));
76
        $form->addFilter($this->getFilter('secure'));
77
    }
78
}
79