@@ 8-49 (lines=42) @@ | ||
5 | /** |
|
6 | * Class LocatorForm |
|
7 | */ |
|
8 | class LocatorBootstrapForm extends BootstrapForm |
|
9 | { |
|
10 | ||
11 | /** |
|
12 | * LocatorForm constructor. |
|
13 | * @param Controller $controller |
|
14 | * @param string $name |
|
15 | */ |
|
16 | public function __construct(Controller $controller, $name) |
|
17 | { |
|
18 | ||
19 | $fields = FieldList::create( |
|
20 | TextField::create('Address') |
|
21 | ->setTitle('') |
|
22 | ->setAttribute('placeholder', 'address or zip code') |
|
23 | ); |
|
24 | ||
25 | if (LocationCategory::get()->count() > 0) { |
|
26 | $categories = DropdownField::create('CategoryID') |
|
27 | ->setTitle('') |
|
28 | ->setEmptyString('All Categories') |
|
29 | ->setSource(LocationCategory::get()->map()); |
|
30 | $fields->push($categories); |
|
31 | } |
|
32 | ||
33 | $this->extend('updateLocatorFormFields', $fields); |
|
34 | ||
35 | $actions = FieldList::create( |
|
36 | FormAction::create('doFilterLocations') |
|
37 | ->setTitle('Search') |
|
38 | ); |
|
39 | ||
40 | $this->extend('updateLocatorFormActions', $actions); |
|
41 | ||
42 | $validator = RequiredFields::create(); |
|
43 | ||
44 | $this->extend('updateLocatorFormRequiredFields', $validator); |
|
45 | ||
46 | parent::__construct($controller, $name, $fields, $actions, $validator); |
|
47 | } |
|
48 | ||
49 | } |
|
50 | ||
51 | } |
@@ 6-47 (lines=42) @@ | ||
3 | /** |
|
4 | * Class LocatorForm |
|
5 | */ |
|
6 | class LocatorForm extends Form |
|
7 | { |
|
8 | ||
9 | /** |
|
10 | * LocatorForm constructor. |
|
11 | * @param Controller $controller |
|
12 | * @param string $name |
|
13 | */ |
|
14 | public function __construct(Controller $controller, $name) |
|
15 | { |
|
16 | ||
17 | $fields = FieldList::create( |
|
18 | TextField::create('Address') |
|
19 | ->setTitle('') |
|
20 | ->setAttribute('placeholder', 'address or zip code') |
|
21 | ); |
|
22 | ||
23 | if (LocationCategory::get()->count() > 0) { |
|
24 | $categories = DropdownField::create('CategoryID') |
|
25 | ->setTitle('') |
|
26 | ->setEmptyString('All Categories') |
|
27 | ->setSource(LocationCategory::get()->map()); |
|
28 | $fields->push($categories); |
|
29 | } |
|
30 | ||
31 | $this->extend('updateLocatorFormFields', $fields); |
|
32 | ||
33 | $actions = FieldList::create( |
|
34 | FormAction::create('doFilterLocations') |
|
35 | ->setTitle('Search') |
|
36 | ); |
|
37 | ||
38 | $this->extend('updateLocatorFormActions', $actions); |
|
39 | ||
40 | $validator = RequiredFields::create(); |
|
41 | ||
42 | $this->extend('updateLocatorFormRequiredFields', $validator); |
|
43 | ||
44 | parent::__construct($controller, $name, $fields, $actions, $validator); |
|
45 | } |
|
46 | ||
47 | } |