Passed
Pull Request — master (#372)
by Robbie
03:33
created

EditFormFactory::getFormFields()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 11
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 5
nc 2
nop 3
dl 0
loc 11
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace DNADesign\Elemental\Forms;
4
5
use SilverStripe\Control\RequestHandler;
6
use SilverStripe\Forms\DefaultFormFactory;
7
use SilverStripe\Forms\HTMLEditor\HTMLEditorField;
8
9
class EditFormFactory extends DefaultFormFactory
10
{
11
    public function getForm(RequestHandler $controller = null, $name = self::DEFAULT_NAME, $context = [])
12
    {
13
        $form = parent::getForm($controller, $name, $context);
14
15
        // Remove divider lines between form fields
16
        $form->addExtraClass('form--no-dividers');
17
18
        return $form;
19
    }
20
21
    protected function getFormFields(RequestHandler $controller = null, $name, $context = [])
22
    {
23
        $fields = parent::getFormFields($controller, $name, $context);
24
25
        /** @var HTMLEditorField $contentField */
26
        $contentField = $fields->fieldByName('Root.Main.HTML');
27
        if ($contentField) {
0 ignored issues
show
introduced by
$contentField is of type SilverStripe\Forms\HTMLEditor\HTMLEditorField, thus it always evaluated to true. If $contentField can have other possible types, add them to src/Forms/EditFormFactory.php:25
Loading history...
28
            $contentField->setRows(5);
29
        }
30
31
        return $fields;
32
    }
33
}
34
35