From 938d2059fac6ed0bff0c54094c96249126221eed Mon Sep 17 00:00:00 2001 From: Kirk Mayo Date: Mon, 10 Feb 2014 12:40:20 +1300 Subject: [PATCH 1/2] NEW: Added a numeric field and associated png NEW: Setup translations for number field NEW: extend fromEditableTextfield use number class --- .../model/formfields/EditableNumericField.php | 34 ++++++++++++++++++ images/editablenumericfield.png | Bin 0 -> 525 bytes lang/en.yml | 5 +++ 3 files changed, 39 insertions(+) create mode 100755 code/model/formfields/EditableNumericField.php create mode 100644 images/editablenumericfield.png diff --git a/code/model/formfields/EditableNumericField.php b/code/model/formfields/EditableNumericField.php new file mode 100755 index 0000000..0c7de32 --- /dev/null +++ b/code/model/formfields/EditableNumericField.php @@ -0,0 +1,34 @@ +getSetting('Rows') && $this->getSetting('Rows') > 1) { + $taf = new NumericField($this->Name, $this->Title); + $taf->setRows($this->getSetting('Rows')); + $taf->addExtraClass('number'); + return $taf; + } + else { + $taf = new NumericField($this->Name, $this->Title, null, $this->getSetting('MaxLength')); + $taf->addExtraClass('number'); + return $taf; + + } + } +} diff --git a/images/editablenumericfield.png b/images/editablenumericfield.png new file mode 100644 index 0000000000000000000000000000000000000000..088fe24a059bbb87c980ce72f6f592ce1f6fa6e0 GIT binary patch literal 525 zcmV+o0`mQdP)9OmXW*rN zlopbgs%-}Tgqg*AzxSUBz9?94W4Ja65mW^A@1Qhm4AQfC5#iovP*_y-S9)GTZ0{o| zMteyi!|g&@BbU1ZLEVY>kjZ2qo6T}lE|-G`N%jv_C={U4Xn7_nBQO-Y z!UCZT!+_ar=G8ElBngJYA?2IR1_pxx$g&K!ZHEiBUauja&x0Tc&}=rTrYH*KOxyG$)Bff?((KIk>J1{eBq&Cquz{&lF+ zA?Fo%Q29ysf1ko%b37GKA<$P>@7un4Mo_0vSNVx`l^>(ge+d!PUxxYsWIT78)XK9^ P00000NkvXXu0mjfgUjU8 literal 0 HcmV?d00001 diff --git a/lang/en.yml b/lang/en.yml index a8492e1..c2949d7 100644 --- a/lang/en.yml +++ b/lang/en.yml @@ -102,6 +102,11 @@ en: PLURALNAME: 'Text Fields' SINGULARNAME: 'Text Field' TEXTLENGTH: 'Text length' + EditableNumericField: + NUMBERROWS: 'Number of rows' + PLURALNAME: 'Number Fields' + SINGULARNAME: 'Number Field' + TEXTLENGTH: 'Number length' EditableUploadField: SELECTUPLOADFOLDER: 'Select upload folder' FieldEditor: From be573dcd3c02496ef4958730767ded55d1dc50f2 Mon Sep 17 00:00:00 2001 From: Kirk Mayo Date: Tue, 11 Feb 2014 09:11:18 +1300 Subject: [PATCH 2/2] NEW: Set MinLength and MaxLength to numeric fields BUG: replaced spaces with tabs to meet coding conventions --- code/model/formfields/EditableNumericField.php | 3 +-- code/model/formfields/EditableTextField.php | 7 ++++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/code/model/formfields/EditableNumericField.php b/code/model/formfields/EditableNumericField.php index 0c7de32..1a33fde 100755 --- a/code/model/formfields/EditableNumericField.php +++ b/code/model/formfields/EditableNumericField.php @@ -27,8 +27,7 @@ class EditableNumericField extends EditableTextField { else { $taf = new NumericField($this->Name, $this->Title, null, $this->getSetting('MaxLength')); $taf->addExtraClass('number'); - return $taf; - + return $taf; } } } diff --git a/code/model/formfields/EditableTextField.php b/code/model/formfields/EditableTextField.php index 5cc2f0f..88a1778 100755 --- a/code/model/formfields/EditableTextField.php +++ b/code/model/formfields/EditableTextField.php @@ -23,10 +23,11 @@ class EditableTextField extends EditableFormField { $extraFields = new FieldList( new FieldGroup(_t('EditableTextField.TEXTLENGTH', 'Text length'), - new TextField($this->getSettingName('MinLength'), "", $min), - new TextField($this->getSettingName('MaxLength'), " - ", $max) + new NumericField($this->getSettingName('MinLength'), "", $min), + new NumericField($this->getSettingName('MaxLength'), " - ", $max) ), - new TextField($this->getSettingName('Rows'), _t('EditableTextField.NUMBERROWS', 'Number of rows'), $rows) + new NumericField($this->getSettingName('Rows'), _t('EditableTextField.NUMBERROWS', + 'Number of rows'), $rows) ); $fields->merge($extraFields);