EditableEmailField::getFormField()   A
last analyzed

Complexity

Conditions 2
Paths 1

Size

Total Lines 9
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 5
nc 1
nop 0
dl 0
loc 9
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace SilverStripe\UserForms\Model\EditableFormField;
4
5
use SilverStripe\Forms\EmailField;
6
use SilverStripe\UserForms\Model\EditableFormField;
7
8
/**
9
 * EditableEmailField
10
 *
11
 * Allow users to define a validating editable email field for a UserDefinedForm
12
 *
13
 * @package userforms
14
 */
15
16
class EditableEmailField extends EditableFormField
17
{
18
    private static $singular_name = 'Email Field';
0 ignored issues
show
introduced by
The private property $singular_name is not used, and could be removed.
Loading history...
19
20
    private static $plural_name = 'Email Fields';
0 ignored issues
show
introduced by
The private property $plural_name is not used, and could be removed.
Loading history...
21
22
    private static $has_placeholder = true;
0 ignored issues
show
introduced by
The private property $has_placeholder is not used, and could be removed.
Loading history...
23
24
    private static $table_name = 'EditableEmailField';
0 ignored issues
show
introduced by
The private property $table_name is not used, and could be removed.
Loading history...
25
26
    public function getSetsOwnError()
27
    {
28
        return true;
29
    }
30
31
    public function getFormField()
32
    {
33
        $field = EmailField::create($this->Name, $this->Title ?: false, $this->Default)
34
            ->setFieldHolderTemplate(EditableFormField::class . '_holder')
35
            ->setTemplate(EditableFormField::class);
36
37
        $this->doUpdateFormField($field);
38
39
        return $field;
40
    }
41
42
    /**
43
     * Updates a formfield with the additional metadata specified by this field
44
     *
45
     * @param FormField $field
0 ignored issues
show
Bug introduced by
The type SilverStripe\UserForms\M...ableFormField\FormField 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...
46
     */
47
    protected function updateFormField($field)
48
    {
49
        parent::updateFormField($field);
50
51
        $field->setAttribute('data-rule-email', true);
52
    }
53
}
54