FIX: Fixes #833 added validation for minimum and maximum length

This commit is contained in:
Jose Pereira 2019-01-16 11:15:53 +13:00
parent 66576b9f3b
commit 2ac6ae6a47

View File

@ -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)
] ]
) )
]); ]);