ReadonlyTagField   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 2
eloc 9
dl 0
loc 26
c 0
b 0
f 0
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A Field() 0 13 2
1
<?php
2
3
namespace SilverStripe\TagField;
4
5
use SilverStripe\Forms\ReadonlyField;
6
7
/**
8
 * A readonly extension of TagField useful for non-editable items within the CMS.
9
 *
10
 * @package forms
11
 * @subpackage fields
12
 */
13
class ReadonlyTagField extends TagField
14
{
15
    /**
16
     * {@inheritDoc}
17
     */
18
    protected $readonly = true;
19
20
    /**
21
     * Render the readonly field as HTML.
22
     *
23
     * @param array $properties
24
     * @return HTMLText
0 ignored issues
show
Bug introduced by
The type SilverStripe\TagField\HTMLText was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
25
     */
26
    public function Field($properties = array())
27
    {
28
        $options = array();
29
30
        foreach ($this->getOptions()->filter('Selected', true) as $option) {
31
            $options[] = $option->Title;
32
        }
33
34
        $field = ReadonlyField::create($this->name . '_Readonly', $this->title);
35
36
        $field->setForm($this->form);
37
        $field->setValue(implode(', ', $options));
38
        return $field->Field();
39
    }
40
}
41