mirror of
https://github.com/silverstripe/silverstripe-userforms.git
synced 2024-10-22 17:05:42 +02:00
Merge pull request #849 from josepereira245/issue/833
FIX: Fixes #833 added validation for minimum and maximum length
This commit is contained in:
commit
305cf39b32
@ -101,6 +101,23 @@ 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(_t(
|
||||||
|
__CLASS__ . 'MINMAXLENGTHCHECK',
|
||||||
|
'Minimum length should be less than the Maximum length.'
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
|
return $result;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return FieldList
|
* @return FieldList
|
||||||
*/
|
*/
|
||||||
@ -115,6 +132,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)
|
||||||
|
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
]);
|
]);
|
||||||
|
@ -208,6 +208,7 @@ en:
|
|||||||
RANGE_TO: to
|
RANGE_TO: to
|
||||||
SINGULARNAME: 'Text Field'
|
SINGULARNAME: 'Text Field'
|
||||||
TEXTLENGTH: 'Allowed text length'
|
TEXTLENGTH: 'Allowed text length'
|
||||||
|
MINMAXLENGTHCHECK: 'Minimum length should be less than the Maximum length.'
|
||||||
SilverStripe\UserForms\Model\EditableFormField\Validator:
|
SilverStripe\UserForms\Model\EditableFormField\Validator:
|
||||||
REQUIRED_ERROR: 'Form fields cannot be required and have conditional display rules.'
|
REQUIRED_ERROR: 'Form fields cannot be required and have conditional display rules.'
|
||||||
SilverStripe\UserForms\Model\Recipient\EmailRecipient:
|
SilverStripe\UserForms\Model\Recipient\EmailRecipient:
|
||||||
|
Loading…
Reference in New Issue
Block a user