1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* Moo_EditableFieldText is an object representing text field created by CMS admin. |
5
|
|
|
* |
6
|
|
|
* @package editablefield |
7
|
|
|
* |
8
|
|
|
* @author Mohamed Alsharaf <[email protected]> |
9
|
|
|
*/ |
10
|
|
|
class Moo_EditableFieldText extends Moo_EditableField |
11
|
|
|
{ |
12
|
|
|
private static $singular_name = 'Text Field'; |
13
|
|
|
private static $plural_name = 'Text Fields'; |
14
|
|
|
|
15
|
|
|
/** |
16
|
|
|
* List of allowed custom settings fields. |
17
|
|
|
* |
18
|
|
|
* @var array |
19
|
|
|
*/ |
20
|
|
|
protected $customSettingsFields = [ |
21
|
|
|
'MinLength', 'MaxLength', 'Rows', |
22
|
|
|
]; |
23
|
|
|
|
24
|
|
|
/** |
25
|
|
|
* Get extra configuration fields. |
26
|
|
|
* |
27
|
|
|
* @return array |
28
|
|
|
*/ |
29
|
1 |
|
public function getFieldConfiguration() |
30
|
|
|
{ |
31
|
1 |
|
$min = ($this->getSetting('MinLength')) ? $this->getSetting('MinLength') : ''; |
32
|
1 |
|
$max = ($this->getSetting('MaxLength')) ? $this->getSetting('MaxLength') : ''; |
33
|
|
|
|
34
|
1 |
|
$rows = ($this->getSetting('Rows')) ? $this->getSetting('Rows') : '1'; |
35
|
|
|
|
36
|
|
|
return [ |
37
|
1 |
|
$learnMoreField = FieldGroup::create( |
38
|
1 |
|
_t('Moo_EditableFieldText.TEXTLENGTH', 'Text length'), |
39
|
1 |
|
new NumericField($this->getSettingName('MinLength'), 'Min', $min), |
40
|
1 |
|
new NumericField($this->getSettingName('MaxLength'), 'Max', $max) |
41
|
1 |
|
), |
42
|
1 |
|
new NumericField($this->getSettingName('Rows'), _t('Moo_EditableFieldText.NUMBERROWS', 'Number of rows'), $rows), |
43
|
1 |
|
]; |
44
|
|
|
} |
45
|
|
|
|
46
|
|
|
/** |
47
|
|
|
* @return TextareaField|TextField |
48
|
|
|
*/ |
49
|
1 |
|
protected function initFormField() |
50
|
|
|
{ |
51
|
1 |
|
if ($this->getSetting('Rows') && $this->getSetting('Rows') > 1) { |
52
|
1 |
|
$textareaField = new TextareaField($this->Name, $this->Title); |
53
|
1 |
|
$textareaField->setRows($this->getSetting('Rows')); |
54
|
|
|
|
55
|
1 |
|
return $textareaField; |
56
|
|
|
} |
57
|
|
|
|
58
|
1 |
|
return new TextField($this->Name, $this->Title, null, $this->getSetting('MaxLength')); |
59
|
|
|
} |
60
|
|
|
} |
61
|
|
|
|