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 Dealer\Model\DealerQuery; |
18
|
|
|
use Thelia\Form\BaseForm; |
19
|
|
|
use Thelia\Model\Folder; |
20
|
|
|
use Thelia\Model\FolderQuery; |
21
|
|
|
|
22
|
|
|
/** |
23
|
|
|
* Class FolderLinkForm |
24
|
|
|
* @package Dealer\Form |
25
|
|
|
*/ |
26
|
|
|
class FolderLinkForm extends BaseForm |
27
|
|
|
{ |
28
|
|
|
/** |
29
|
|
|
* @inheritDoc |
30
|
|
|
*/ |
31
|
|
|
protected function buildForm() |
32
|
|
|
{ |
33
|
|
|
$this->formBuilder |
34
|
|
|
->add("folder_id", "choice", array( |
35
|
|
|
"choices" => $this->getAvailableFolder(), |
36
|
|
|
"label" => $this->translator->trans("Folder", [], Dealer::MESSAGE_DOMAIN), |
37
|
|
|
"label_attr" => ["for" => "attr-dealer-folder-link-folder"], |
38
|
|
|
"required" => true, |
39
|
|
|
"attr" => array() |
40
|
|
|
)) |
41
|
|
|
->add("dealer_id", "choice", array( |
42
|
|
|
"choices" => $this->getAvailableDealer(), |
43
|
|
|
"label" => $this->translator->trans("Dealer", [], Dealer::MESSAGE_DOMAIN), |
44
|
|
|
"label_attr" => ["for" => "attr-dealer-folder-link-dealer"], |
45
|
|
|
"required" => true, |
46
|
|
|
"attr" => array() |
47
|
|
|
)); |
48
|
|
|
} |
49
|
|
|
|
50
|
|
|
public function getName() |
51
|
|
|
{ |
52
|
|
|
return "dealer_folder_link_create"; |
53
|
|
|
} |
54
|
|
|
|
55
|
|
|
protected function getAvailableFolder() |
56
|
|
|
{ |
57
|
|
|
$folders = FolderQuery::create()->find(); |
58
|
|
|
$choices = []; |
59
|
|
|
|
60
|
|
|
/** @var Folder $folder */ |
61
|
|
|
foreach ($folders as $folder) { |
62
|
|
|
$choices[$folder->getId()] = $folder->getTitle(); |
63
|
|
|
} |
64
|
|
|
|
65
|
|
|
return $choices; |
66
|
|
|
} |
67
|
|
|
|
68
|
|
|
protected function getAvailableDealer() |
69
|
|
|
{ |
70
|
|
|
$dealers = DealerQuery::create()->find(); |
71
|
|
|
$choices = []; |
72
|
|
|
foreach ($dealers as $dealer) { |
73
|
|
|
$choices[$dealer->getId()] = $dealer->getTitle(); |
74
|
|
|
} |
75
|
|
|
|
76
|
|
|
return $choices; |
77
|
|
|
} |
78
|
|
|
} |
79
|
|
|
|