|
1
|
|
|
<?php |
|
2
|
|
|
/*************************************************************************************/ |
|
3
|
|
|
/* This file is part of the Thelia package. */ |
|
4
|
|
|
/* */ |
|
5
|
|
|
/* Copyright (c) OpenStudio */ |
|
6
|
|
|
/* email : [email protected] */ |
|
7
|
|
|
/* web : http://www.thelia.net */ |
|
8
|
|
|
/* */ |
|
9
|
|
|
/* For the full copyright and license information, please view the LICENSE.txt */ |
|
10
|
|
|
/* file that was distributed with this source code. */ |
|
11
|
|
|
/*************************************************************************************/ |
|
12
|
|
|
/*************************************************************************************/ |
|
13
|
|
|
|
|
14
|
|
|
namespace Dealer\Form; |
|
15
|
|
|
|
|
16
|
|
|
use Dealer\Dealer; |
|
17
|
|
|
use Symfony\Component\Validator\Constraints\NotBlank; |
|
18
|
|
|
use Thelia\Form\BaseForm; |
|
19
|
|
|
use Thelia\Model\Country; |
|
20
|
|
|
use Thelia\Model\CountryQuery; |
|
21
|
|
|
|
|
22
|
|
|
/** |
|
23
|
|
|
* Class DealerForm |
|
24
|
|
|
* @package Dealer\Form |
|
25
|
|
|
*/ |
|
26
|
|
|
class DealerForm extends BaseForm |
|
27
|
|
|
{ |
|
28
|
|
|
|
|
29
|
|
|
/** |
|
30
|
|
|
* |
|
31
|
|
|
* in this function you add all the fields you need for your Form. |
|
32
|
|
|
* Form this you have to call add method on $this->formBuilder attribute : |
|
33
|
|
|
* |
|
34
|
|
|
* $this->formBuilder->add("name", "text") |
|
35
|
|
|
* ->add("email", "email", array( |
|
36
|
|
|
* "attr" => array( |
|
37
|
|
|
* "class" => "field" |
|
38
|
|
|
* ), |
|
39
|
|
|
* "label" => "email", |
|
40
|
|
|
* "constraints" => array( |
|
41
|
|
|
* new \Symfony\Component\Validator\Constraints\NotBlank() |
|
42
|
|
|
* ) |
|
43
|
|
|
* ) |
|
44
|
|
|
* ) |
|
45
|
|
|
* ->add('age', 'integer'); |
|
46
|
|
|
* |
|
47
|
|
|
* @return null |
|
48
|
|
|
*/ |
|
49
|
|
|
protected function buildForm() |
|
50
|
|
|
{ |
|
51
|
|
|
$this->formBuilder |
|
52
|
|
|
->add("title", "text", array( |
|
53
|
|
|
"label" => $this->translator->trans("Title", [], Dealer::MESSAGE_DOMAIN), |
|
54
|
|
|
"label_attr" => ["for" => "dealer.title"], |
|
55
|
|
|
"required" => true, |
|
56
|
|
|
"constraints" => array(new NotBlank(), ), |
|
57
|
|
|
"attr" => array() |
|
58
|
|
|
)) |
|
59
|
|
|
->add("description", "text", array( |
|
60
|
|
|
"label" => $this->translator->trans("Description", [], Dealer::MESSAGE_DOMAIN), |
|
61
|
|
|
"label_attr" => ["for" => "dealer.description"], |
|
62
|
|
|
"required" => false, |
|
63
|
|
|
"attr" => array() |
|
64
|
|
|
)) |
|
65
|
|
|
->add("big_description", "text", array( |
|
66
|
|
|
"label" => $this->translator->trans("Complex Description", [], Dealer::MESSAGE_DOMAIN), |
|
67
|
|
|
"label_attr" => ["for" => "dealer.big_description"], |
|
68
|
|
|
"required" => false, |
|
69
|
|
|
"attr" => array() |
|
70
|
|
|
)) |
|
71
|
|
|
->add("hard_open_hour", "text", array( |
|
72
|
|
|
"label" => $this->translator->trans("Open hour text", [], Dealer::MESSAGE_DOMAIN), |
|
73
|
|
|
"label_attr" => ["for" => "dealer.hard_open_hour"], |
|
74
|
|
|
"required" => false, |
|
75
|
|
|
"attr" => array() |
|
76
|
|
|
)) |
|
77
|
|
|
->add("access", "text", array( |
|
78
|
|
|
"label" => $this->translator->trans("Access", [], Dealer::MESSAGE_DOMAIN), |
|
79
|
|
|
"label_attr" => ["for" => "dealer.access"], |
|
80
|
|
|
"required" => false, |
|
81
|
|
|
"attr" => array() |
|
82
|
|
|
)) |
|
83
|
|
|
->add("address1", "text", array( |
|
84
|
|
|
"label" => $this->translator->trans("Address1", [], Dealer::MESSAGE_DOMAIN), |
|
85
|
|
|
"label_attr" => ["for" => "dealer.address1"], |
|
86
|
|
|
"required" => true, |
|
87
|
|
|
"constraints" => array(new NotBlank(), ), |
|
88
|
|
|
"attr" => array() |
|
89
|
|
|
)) |
|
90
|
|
|
->add("address2", "text", array( |
|
91
|
|
|
"label" => $this->translator->trans("Address2", [], Dealer::MESSAGE_DOMAIN), |
|
92
|
|
|
"label_attr" => ["for" => "dealer.address2"], |
|
93
|
|
|
"required" => false, |
|
94
|
|
|
"attr" => array() |
|
95
|
|
|
)) |
|
96
|
|
|
->add("address3", "text", array( |
|
97
|
|
|
"label" => $this->translator->trans("Address3", [], Dealer::MESSAGE_DOMAIN), |
|
98
|
|
|
"label_attr" => ["for" => "dealer.address3"], |
|
99
|
|
|
"required" => false, |
|
100
|
|
|
"attr" => array() |
|
101
|
|
|
)) |
|
102
|
|
|
->add("zipcode", "text", array( |
|
103
|
|
|
"label" => $this->translator->trans("Zipcode", [], Dealer::MESSAGE_DOMAIN), |
|
104
|
|
|
"label_attr" => ["for" => "dealer.zipcode"], |
|
105
|
|
|
"required" => true, |
|
106
|
|
|
"constraints" => array(new NotBlank(), ), |
|
107
|
|
|
"attr" => array() |
|
108
|
|
|
)) |
|
109
|
|
|
->add("city", "text", array( |
|
110
|
|
|
"label" => $this->translator->trans("City", [], Dealer::MESSAGE_DOMAIN), |
|
111
|
|
|
"label_attr" => ["for" => "dealer.city"], |
|
112
|
|
|
"required" => true, |
|
113
|
|
|
"constraints" => array(new NotBlank(), ), |
|
114
|
|
|
"attr" => array() |
|
115
|
|
|
)) |
|
116
|
|
|
->add("country_id", "choice", array( |
|
117
|
|
|
"choices" => $this->getCountries(), |
|
118
|
|
|
"label" => $this->translator->trans("Country", [], Dealer::MESSAGE_DOMAIN), |
|
119
|
|
|
"label_attr" => ["for" => "dealer.country"], |
|
120
|
|
|
"required" => true, |
|
121
|
|
|
"attr" => array() |
|
122
|
|
|
)) |
|
123
|
|
|
->add("locale", "text", array( |
|
124
|
|
|
"constraints" => array( |
|
125
|
|
|
new NotBlank(), |
|
126
|
|
|
), |
|
127
|
|
|
"label_attr" => array("for" => "locale_create"), |
|
128
|
|
|
)); |
|
129
|
|
|
} |
|
130
|
|
|
|
|
131
|
|
|
protected function getCountries() |
|
132
|
|
|
{ |
|
133
|
|
|
$countries = CountryQuery::create()->find(); |
|
134
|
|
|
$retour = []; |
|
135
|
|
|
/** @var Country $country */ |
|
136
|
|
|
foreach ($countries as $country) { |
|
137
|
|
|
$retour[$country->getId()] = $country->getTitle(); |
|
138
|
|
|
} |
|
139
|
|
|
|
|
140
|
|
|
return $retour; |
|
141
|
|
|
} |
|
142
|
|
|
|
|
143
|
|
|
public function getName() |
|
144
|
|
|
{ |
|
145
|
|
|
return "dealer_create"; |
|
146
|
|
|
} |
|
147
|
|
|
} |
|
148
|
|
|
|