Passed
Push — master ( b91912...ff5896 )
by Robbie
07:30 queued 10s
created

ElementalCMSMainExtension::updateSearchForm()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 3
nc 2
nop 1
dl 0
loc 6
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace DNADesign\Elemental\Extensions;
4
5
use SilverStripe\Core\Extension;
6
use SilverStripe\Forms\DropdownField;
7
use SilverStripe\Forms\Form;
8
9
class ElementalCMSMainExtension extends Extension
10
{
11
    /**
12
     * Remove the empty default string on the class filter, which adds "All pages" again. This is already
13
     * added by ElementSiteTreeFilterSearch.
14
     *
15
     * @param Form $form
16
     */
17
    public function updateSearchForm(Form $form)
18
    {
19
        /** @var DropdownField $filterField */
20
        $filterField = $form->Fields()->fieldByName('Search__FilterClass');
21
        if ($filterField) {
0 ignored issues
show
introduced by Robbie Averill
$filterField is of type SilverStripe\Forms\DropdownField, thus it always evaluated to true.
Loading history...
22
            $filterField->setEmptyString('')->setHasEmptyDefault(false);
23
        }
24
    }
25
}
26