mirror of
https://github.com/silverstripe/silverstripe-userforms.git
synced 2024-10-22 17:05:42 +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 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
|
||||
*/
|
||||
@ -115,6 +130,7 @@ class EditableTextField extends EditableFormField
|
||||
NumericField::create('MinLength', false),
|
||||
LiteralField::create('RangeLength', _t(__CLASS__.".RANGE_TO", "to")),
|
||||
NumericField::create('MaxLength', false)
|
||||
|
||||
]
|
||||
)
|
||||
]);
|
||||
|
Loading…
Reference in New Issue
Block a user