Merge pull request #188 from silverstripe-rebelalliance/numeric

NEW: Added a numeric field
This commit is contained in:
Will Rossiter 2014-02-11 11:20:47 +13:00
commit 12ccea0d48
4 changed files with 42 additions and 3 deletions

View File

@ -0,0 +1,33 @@
<?php
/**
* EditableNumericField
*
* This control represents a user-defined numeric field in a user defined form
*
* @package userforms
*/
class EditableNumericField extends EditableTextField {
private static $singular_name = 'Numeric Field';
private static $plural_name = 'Numeric Fields';
/**
* @return TextareaField|TextField
*/
public function getFormField() {
if($this->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;
}
}
}

View File

@ -23,10 +23,11 @@ class EditableTextField extends EditableFormField {
$extraFields = new FieldList( $extraFields = new FieldList(
new FieldGroup(_t('EditableTextField.TEXTLENGTH', 'Text length'), new FieldGroup(_t('EditableTextField.TEXTLENGTH', 'Text length'),
new TextField($this->getSettingName('MinLength'), "", $min), new NumericField($this->getSettingName('MinLength'), "", $min),
new TextField($this->getSettingName('MaxLength'), " - ", $max) 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); $fields->merge($extraFields);

Binary file not shown.

After

Width:  |  Height:  |  Size: 525 B

View File

@ -102,6 +102,11 @@ en:
PLURALNAME: 'Text Fields' PLURALNAME: 'Text Fields'
SINGULARNAME: 'Text Field' SINGULARNAME: 'Text Field'
TEXTLENGTH: 'Text length' TEXTLENGTH: 'Text length'
EditableNumericField:
NUMBERROWS: 'Number of rows'
PLURALNAME: 'Number Fields'
SINGULARNAME: 'Number Field'
TEXTLENGTH: 'Number length'
EditableUploadField: EditableUploadField:
SELECTUPLOADFOLDER: 'Select upload folder' SELECTUPLOADFOLDER: 'Select upload folder'
FieldEditor: FieldEditor: