Completed
Push — master ( 4af71b...17ddfa )
by Sam
18:54
created

EditFactory   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 5

Importance

Changes 0
Metric Value
dl 0
loc 25
rs 10
c 0
b 0
f 0
wmc 2
lcom 0
cbo 5

2 Methods

Rating   Name   Duplication   Size   Complexity  
A EditFormFactory::getFormFields() 0 9 1
A EditFormFactory::getFormActions() 0 8 1
1
<?php
2
3
namespace SilverStripe\Forms\Tests\FormFactoryTest;
4
5
use SilverStripe\Control\RequestHandler;
6
use SilverStripe\Forms\DefaultFormFactory;
7
use SilverStripe\Forms\FieldList;
8
use SilverStripe\Forms\FormAction;
9
use SilverStripe\Forms\HiddenField;
10
use SilverStripe\Forms\TextField;
11
12
/**
13
 * Test factory
14
 */
15
class EditFormFactory extends DefaultFormFactory
16
{
17
    private static $extensions = [
18
        ControllerExtension::class
19
    ];
20
21
    protected function getFormFields(RequestHandler $controller = null, $name, $context = [])
22
    {
23
        $fields = new FieldList(
24
            new HiddenField('ID'),
25
            new TextField('Title')
26
        );
27
        $this->invokeWithExtensions('updateFormFields', $fields, $controller, $name, $context);
28
        return $fields;
29
    }
30
31
    protected function getFormActions(RequestHandler $controller = null, $name, $context = [])
32
    {
33
        $actions = new FieldList(
34
            new FormAction('save', 'Save')
35
        );
36
        $this->invokeWithExtensions('updateFormActions', $actions, $controller, $name, $context);
37
        return $actions;
38
    }
39
}
40