@@ -18,88 +18,88 @@ |
||
18 | 18 | */ |
19 | 19 | class LocatorForm extends Form |
20 | 20 | { |
21 | - /** |
|
22 | - * LocatorForm constructor. |
|
23 | - * @param Controller $controller |
|
24 | - * @param string $name |
|
25 | - */ |
|
26 | - public function __construct(Controller $controller, $name) |
|
27 | - { |
|
21 | + /** |
|
22 | + * LocatorForm constructor. |
|
23 | + * @param Controller $controller |
|
24 | + * @param string $name |
|
25 | + */ |
|
26 | + public function __construct(Controller $controller, $name) |
|
27 | + { |
|
28 | 28 | |
29 | - $fields = FieldList::create( |
|
30 | - TextField::create('Address') |
|
31 | - ->setTitle('') |
|
32 | - ->setAttribute('placeholder', 'address or zip code') |
|
33 | - ); |
|
29 | + $fields = FieldList::create( |
|
30 | + TextField::create('Address') |
|
31 | + ->setTitle('') |
|
32 | + ->setAttribute('placeholder', 'address or zip code') |
|
33 | + ); |
|
34 | 34 | |
35 | - $pageCategories = Locator::locator_categories_by_locator($controller->data()->ID); |
|
36 | - if ($pageCategories && $pageCategories->count() > 0) { |
|
37 | - $categories = false; |
|
38 | - } else { |
|
39 | - $categories = Locator::get_all_categories(); |
|
40 | - if ($categories->count() < 1) { |
|
41 | - $categories = false; |
|
42 | - } |
|
43 | - } |
|
35 | + $pageCategories = Locator::locator_categories_by_locator($controller->data()->ID); |
|
36 | + if ($pageCategories && $pageCategories->count() > 0) { |
|
37 | + $categories = false; |
|
38 | + } else { |
|
39 | + $categories = Locator::get_all_categories(); |
|
40 | + if ($categories->count() < 1) { |
|
41 | + $categories = false; |
|
42 | + } |
|
43 | + } |
|
44 | 44 | |
45 | - if ($categories) { |
|
46 | - $categoriesField = DropdownField::create('CategoryID') |
|
47 | - ->setTitle('') |
|
48 | - ->setEmptyString('all categories') |
|
49 | - ->setSource($categories->map()); |
|
50 | - $fields->push($categoriesField); |
|
51 | - } |
|
45 | + if ($categories) { |
|
46 | + $categoriesField = DropdownField::create('CategoryID') |
|
47 | + ->setTitle('') |
|
48 | + ->setEmptyString('all categories') |
|
49 | + ->setSource($categories->map()); |
|
50 | + $fields->push($categoriesField); |
|
51 | + } |
|
52 | 52 | |
53 | - if ($controller->getShowRadius()) { |
|
54 | - $radiusArray = array_values($controller->getRadii()); |
|
55 | - $this->extend('overrideRadiusArray', $radiusArray); |
|
56 | - $fields->push(DropdownField::create('Radius', '', ArrayLib::valuekey($radiusArray)) |
|
57 | - ->setEmptyString('radius')); |
|
58 | - } |
|
53 | + if ($controller->getShowRadius()) { |
|
54 | + $radiusArray = array_values($controller->getRadii()); |
|
55 | + $this->extend('overrideRadiusArray', $radiusArray); |
|
56 | + $fields->push(DropdownField::create('Radius', '', ArrayLib::valuekey($radiusArray)) |
|
57 | + ->setEmptyString('radius')); |
|
58 | + } |
|
59 | 59 | |
60 | - $actions = FieldList::create( |
|
61 | - FormAction::create('doFilterLocations') |
|
62 | - ->setTitle('Search') |
|
63 | - ); |
|
60 | + $actions = FieldList::create( |
|
61 | + FormAction::create('doFilterLocations') |
|
62 | + ->setTitle('Search') |
|
63 | + ); |
|
64 | 64 | |
65 | - $validator = $this->getValidator(); |
|
65 | + $validator = $this->getValidator(); |
|
66 | 66 | |
67 | - parent::__construct($controller, $name, $fields, $actions, $validator); |
|
68 | - } |
|
67 | + parent::__construct($controller, $name, $fields, $actions, $validator); |
|
68 | + } |
|
69 | 69 | |
70 | - /** |
|
71 | - * @return null|RequiredFields|\SilverStripe\Forms\Validator |
|
72 | - */ |
|
73 | - public function getValidator() |
|
74 | - { |
|
75 | - $validator = parent::getValidator(); |
|
76 | - if (empty($validator)) { |
|
77 | - if (!$this->validator instanceof RequiredFields) { |
|
78 | - $this->setValidator(RequiredFields::create('Address')); |
|
79 | - } |
|
80 | - $validator = $this->validator; |
|
81 | - } |
|
82 | - $this->extend('updateRequiredFields', $validator); |
|
83 | - return $validator; |
|
84 | - } |
|
70 | + /** |
|
71 | + * @return null|RequiredFields|\SilverStripe\Forms\Validator |
|
72 | + */ |
|
73 | + public function getValidator() |
|
74 | + { |
|
75 | + $validator = parent::getValidator(); |
|
76 | + if (empty($validator)) { |
|
77 | + if (!$this->validator instanceof RequiredFields) { |
|
78 | + $this->setValidator(RequiredFields::create('Address')); |
|
79 | + } |
|
80 | + $validator = $this->validator; |
|
81 | + } |
|
82 | + $this->extend('updateRequiredFields', $validator); |
|
83 | + return $validator; |
|
84 | + } |
|
85 | 85 | |
86 | - /** |
|
87 | - * @return FieldList |
|
88 | - */ |
|
89 | - public function Fields() |
|
90 | - { |
|
91 | - $fields = parent::Fields(); |
|
92 | - $this->extend('updateLocatorFormFields', $fields); |
|
93 | - return $fields; |
|
94 | - } |
|
86 | + /** |
|
87 | + * @return FieldList |
|
88 | + */ |
|
89 | + public function Fields() |
|
90 | + { |
|
91 | + $fields = parent::Fields(); |
|
92 | + $this->extend('updateLocatorFormFields', $fields); |
|
93 | + return $fields; |
|
94 | + } |
|
95 | 95 | |
96 | - /** |
|
97 | - * @return \SilverStripe\Forms\FieldList |
|
98 | - */ |
|
99 | - public function Actions() |
|
100 | - { |
|
101 | - $actions = parent::Actions(); |
|
102 | - $this->extend('updateLocatorActions', $actions); |
|
103 | - return $actions; |
|
104 | - } |
|
96 | + /** |
|
97 | + * @return \SilverStripe\Forms\FieldList |
|
98 | + */ |
|
99 | + public function Actions() |
|
100 | + { |
|
101 | + $actions = parent::Actions(); |
|
102 | + $this->extend('updateLocatorActions', $actions); |
|
103 | + return $actions; |
|
104 | + } |
|
105 | 105 | } |