mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
Merge pull request #9999 from GuySartorelli/patch-2
ENH Use text field's title for validation messages.
This commit is contained in:
commit
d120367b5a
@ -142,12 +142,13 @@ class TextField extends FormField implements TippableFieldInterface
|
||||
public function validate($validator)
|
||||
{
|
||||
if (!is_null($this->maxLength) && mb_strlen($this->value) > $this->maxLength) {
|
||||
$name = strip_tags($this->Title() ? $this->Title() : $this->getName());
|
||||
$validator->validationError(
|
||||
$this->name,
|
||||
_t(
|
||||
'SilverStripe\\Forms\\TextField.VALIDATEMAXLENGTH',
|
||||
'The value for {name} must not exceed {maxLength} characters in length',
|
||||
['name' => $this->getName(), 'maxLength' => $this->maxLength]
|
||||
['name' => $name, 'maxLength' => $this->maxLength]
|
||||
),
|
||||
"validation"
|
||||
);
|
||||
|
Loading…
Reference in New Issue
Block a user