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
|
|
|
protected $customSettingsFields = [ |
15
|
|
|
'MinLength', 'MaxLength', 'Rows', |
16
|
|
|
]; |
17
|
|
|
|
18
|
1 |
|
public function getFieldConfiguration() |
19
|
|
|
{ |
20
|
1 |
|
$min = ($this->getSetting('MinLength')) ? $this->getSetting('MinLength') : ''; |
21
|
1 |
|
$max = ($this->getSetting('MaxLength')) ? $this->getSetting('MaxLength') : ''; |
22
|
|
|
|
23
|
1 |
|
$rows = ($this->getSetting('Rows')) ? $this->getSetting('Rows') : '1'; |
24
|
|
|
|
25
|
|
|
return [ |
26
|
1 |
|
$learnMoreField = FieldGroup::create(_t('Moo_EditableFieldText.TEXTLENGTH', 'Text length'), |
27
|
1 |
|
new NumericField($this->getSettingName('MinLength'), 'Min', $min), |
28
|
1 |
|
new NumericField($this->getSettingName('MaxLength'), 'Max', $max) |
29
|
1 |
|
), |
30
|
1 |
|
new NumericField($this->getSettingName('Rows'), _t('Moo_EditableFieldText.NUMBERROWS', 'Number of rows'), $rows), |
31
|
1 |
|
]; |
32
|
|
|
} |
33
|
|
|
|
34
|
|
|
/** |
35
|
|
|
* @return TextareaField|TextField |
36
|
|
|
*/ |
37
|
1 |
|
protected function initFormField() |
38
|
|
|
{ |
39
|
1 |
|
if ($this->getSetting('Rows') && $this->getSetting('Rows') > 1) { |
40
|
1 |
|
$taf = new TextareaField($this->Name, $this->Title); |
41
|
1 |
|
$taf->setRows($this->getSetting('Rows')); |
42
|
|
|
|
43
|
1 |
|
return $taf; |
44
|
|
|
} else { |
45
|
1 |
|
return new TextField($this->Name, $this->Title, null, $this->getSetting('MaxLength')); |
46
|
|
|
} |
47
|
|
|
} |
48
|
|
|
} |
49
|
|
|
|