These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | |||
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 | $pageCategories = Locator::locator_categories_by_locator($controller->data()->ID); |
||
24 | if ($pageCategories && $pageCategories->count() > 0) { |
||
0 ignored issues
–
show
|
|||
25 | $categories = false; |
||
26 | } else { |
||
27 | $categories = Locator::get_all_categories(); |
||
28 | } |
||
29 | |||
30 | if ($categories) { |
||
31 | $categoriesField = DropdownField::create('CategoryID') |
||
32 | ->setTitle('') |
||
33 | ->setEmptyString('All Categories') |
||
34 | ->setSource($categories->map()); |
||
35 | $fields->push($categoriesField); |
||
36 | } |
||
37 | |||
38 | $actions = FieldList::create( |
||
39 | FormAction::create('doFilterLocations') |
||
40 | ->setTitle('Search') |
||
41 | ); |
||
42 | |||
43 | $validator = RequiredFields::create(); |
||
44 | |||
45 | parent::__construct($controller, $name, $fields, $actions, $validator); |
||
46 | } |
||
47 | |||
48 | } |
Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.