getFieldValidationOptions()   A
last analyzed

Complexity

Conditions 3
Paths 4

Size

Total Lines 10
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 12

Importance

Changes 0
Metric Value
dl 0
loc 10
ccs 0
cts 6
cp 0
rs 9.4285
c 0
b 0
f 0
cc 3
eloc 6
nc 4
nop 0
crap 12
1
<?php
2
3
/**
4
 * Moo_EditableFieldNumeric is an object representing numeric field created by CMS admin.
5
 *
6
 * @package editablefield
7
 *
8
 * @author  Mohamed Alsharaf <[email protected]>
9
 */
10
class Moo_EditableFieldNumeric extends Moo_EditableField
11
{
12
    private static $singular_name   = 'Numeric Field';
13
    private static $plural_name     = 'Numeric Fields';
14
15
    /**
16
     * List of allowed custom settings fields.
17
     *
18
     * @var array
19
     */
20
    protected $customSettingsFields = [
21
        'MinValue', 'MaxValue',
22
    ];
23
24 1
    protected function initFormField()
25
    {
26 1
        $field = new NumericField($this->Name, $this->Title);
27 1
        $field->addExtraClass('number');
28
29 1
        return $field;
30
    }
31
32
    /**
33
     * Get extra validation fields.
34
     *
35
     * @return array
36
     */
37
    public function getFieldValidationOptions()
38
    {
39
        $min = ($this->getSetting('MinValue')) ? $this->getSetting('MinValue') : '';
40
        $max = ($this->getSetting('MaxValue')) ? $this->getSetting('MaxValue') : '';
41
42
        return [
43
            new NumericField($this->getSettingName('MinValue'), _t('Moo_EditableField.MINVALUE', 'Min Value'), $min),
44
            new NumericField($this->getSettingName('MaxValue'), _t('Moo_EditableField.MAXVALUE', 'Max Value'), $max),
45
        ];
46
    }
47
}
48