Moo_EditableFieldDate::initFormField()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 8
ccs 5
cts 5
cp 1
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 5
nc 2
nop 0
crap 2
1
<?php
2
3
/**
4
 * Moo_EditableFieldDate is an object representing date field created by CMS admin.
5
 *
6
 * @package editablefield
7
 *
8
 * @author  Mohamed Alsharaf <[email protected]>
9
 */
10
class Moo_EditableFieldDate extends Moo_EditableField
11
{
12
    private static $singular_name = 'Date Field';
13
    private static $plural_name   = 'Date Fields';
14
15
    /**
16
     * List of allowed custom settings fields.
17
     *
18
     * @var array
19
     */
20
    protected $customSettingsFields = [
21
        'DefaultToToday',
22
    ];
23
24
    /**
25
     * Get extra configuration fields.
26
     *
27
     * @return array
28
     */
29
    public function getFieldConfiguration()
30
    {
31
        $default = ($this->getSetting('DefaultToToday')) ? $this->getSetting('DefaultToToday') : false;
32
        $label   = _t('Moo_EditableField.DEFAULTTOTODAY', 'Default to Today?');
33
34
        return [
35
            new CheckboxField($this->getSettingName('DefaultToToday'), $label, $default),
36
        ];
37
    }
38
39 1
    protected function initFormField()
40
    {
41 1
        $defaultValue = ($this->getSetting('DefaultToToday')) ? date('Y-m-d') : $this->Default;
0 ignored issues
show
Bug introduced by
The property Default does not seem to exist. Did you mean default_cast?

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
42 1
        $field        = new DateField($this->Name, $this->Title, $defaultValue);
43 1
        $field->setConfig('showcalendar', true);
44
45 1
        return $field;
46
    }
47
}
48