Completed
Push — master ( 5851ba...f5a6ee )
by
unknown
47s queued 45s
created

src/Model/ResourceFilter/Dropdown.php (4 issues)

1
<?php
2
3
namespace SilverStripe\CKANRegistry\Model\ResourceFilter;
4
5
use SilverStripe\CKANRegistry\Forms\PresentedOptionsField;
6
use SilverStripe\CKANRegistry\Model\ResourceFilter;
7
use SilverStripe\Forms\DropdownField;
8
use SilverStripe\Forms\FieldList;
9
use SilverStripe\Forms\TextField;
10
11
/**
12
 * Provides a single select option for CKAN resources to be filtered by
13
 */
14
class Dropdown extends ResourceFilter
15
{
16
    private static $db = [
0 ignored issues
show
The private property $db is not used, and could be removed.
Loading history...
17
        'Options' => 'Varchar',
18
    ];
19
20
    private static $table_name = 'CKANFilter_Dropdown';
0 ignored issues
show
The private property $table_name is not used, and could be removed.
Loading history...
21
22
    private static $singular_name = 'Dropdown';
0 ignored issues
show
The private property $singular_name is not used, and could be removed.
Loading history...
23
24
    protected $fieldType = DropdownField::class;
25
26
    public function getCMSFields()
27
    {
28
        $this->beforeUpdateCMSFields(function (FieldList $fields) {
29
            $fields->addFieldToTab('Root.Main', PresentedOptionsField::create(
30
                'Options',
31
                $this->FilterFor,
0 ignored issues
show
Bug Best Practice introduced by
The property FilterFor does not exist on SilverStripe\CKANRegistr...ResourceFilter\Dropdown. Since you implemented __get, consider adding a @property annotation.
Loading history...
32
                _t(__CLASS__ . '.OPTIONS', 'Presented options')
33
            ));
34
        });
35
36
        return parent::getCMSFields();
37
    }
38
}
39