mirror of
https://github.com/silverstripe/silverstripe-userforms.git
synced 2024-06-26 14:39:31 +02:00
FIX: Fixes #833 added validation for minimum and maximum length
This commit is contained in:
parent
66576b9f3b
commit
2ac6ae6a47
|
@ -101,6 +101,21 @@ class EditableTextField extends EditableFormField
|
||||||
return parent::getCMSFields();
|
return parent::getCMSFields();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return ValidationResult
|
||||||
|
*/
|
||||||
|
public function validate()
|
||||||
|
{
|
||||||
|
$result = parent::validate();
|
||||||
|
|
||||||
|
if ($this->MinLength > $this->MaxLength) {
|
||||||
|
$result->addError("Minimum length should be less than the Maximum length.");
|
||||||
|
}
|
||||||
|
|
||||||
|
return $result;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return FieldList
|
* @return FieldList
|
||||||
*/
|
*/
|
||||||
|
@ -115,6 +130,7 @@ class EditableTextField extends EditableFormField
|
||||||
NumericField::create('MinLength', false),
|
NumericField::create('MinLength', false),
|
||||||
LiteralField::create('RangeLength', _t(__CLASS__.".RANGE_TO", "to")),
|
LiteralField::create('RangeLength', _t(__CLASS__.".RANGE_TO", "to")),
|
||||||
NumericField::create('MaxLength', false)
|
NumericField::create('MaxLength', false)
|
||||||
|
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
]);
|
]);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user