Skip to content

Commit 74b8df9

Browse files
committed
Validator: %label trims colon
1 parent 5b94fc6 commit 74b8df9

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

src/Forms/Validator.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,9 @@ public static function formatMessage(Rule $rule, bool $withValue = true)
6969
static $i = -1;
7070
switch ($m[1]) {
7171
case 'name': return $rule->control->getName();
72-
case 'label': return $rule->control instanceof Controls\BaseControl ? $rule->control->translate($rule->control->getCaption()) : null;
72+
case 'label': return $rule->control instanceof Controls\BaseControl
73+
? rtrim($rule->control->translate($rule->control->getCaption()), ':')
74+
: null;
7375
case 'value': return $withValue ? $rule->control->getValue() : $m[0];
7476
default:
7577
$args = is_array($rule->arg) ? $rule->arg : [$rule->arg];

tests/Forms/Rules.formatMessage.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ $form->addText('args3')
2929
->addRule(Form::LENGTH, '%d %d', 1)
3030
->setDefaultValue('xyz');
3131

32-
$form->addText('special', 'Label')
32+
$form->addText('special', 'Label:')
3333
->setRequired()
3434
->addRule(Form::EMAIL, '%label %value is invalid [field %name] %d', $form['special'])
3535
->setDefaultValue('xyz');

0 commit comments

Comments
 (0)