Completed
Pull Request — master (#134)
by Robbie
03:00 queued 01:22
created

performReadonlyTransformation()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 8
rs 9.4285
cc 1
eloc 4
nc 1
nop 0
1
<?php
2
3
namespace DNADesign\Elemental\Forms;
4
5
use SilverStripe\Forms\CompositeField;
6
7
class TextCheckboxGroupField extends CompositeField
8
{
9
    /**
10
     * Set the composite's title to that of the first child
11
     *
12
     * {@inheritDoc}
13
     */
14
    public function __construct(...$children)
15
    {
16
        parent::__construct($children);
17
18
        $this->setTitle($this->getChildren()->first()->Title());
19
    }
20
21
    /**
22
     * Don't use the custom template for readonly states
23
     *
24
     * {@inheritDoc}
25
     */
26
    public function performReadonlyTransformation()
27
    {
28
        $field = parent::performReadonlyTransformation();
29
30
        $field->setTemplate(CompositeField::class);
31
        $field->setTitle(null);
32
33
        return $field;
34
    }
35
}
36