mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-09-30 05:09:06 +02:00
Mark up <time> in validation errors
Allow better localisation of values in JS
This commit is contained in:
parent
a2ee6a76a0
commit
22f232ed4d
@ -7,6 +7,7 @@ use SilverStripe\i18n\i18n;
|
|||||||
use InvalidArgumentException;
|
use InvalidArgumentException;
|
||||||
use SilverStripe\ORM\FieldType\DBDate;
|
use SilverStripe\ORM\FieldType\DBDate;
|
||||||
use SilverStripe\ORM\FieldType\DBDatetime;
|
use SilverStripe\ORM\FieldType\DBDatetime;
|
||||||
|
use SilverStripe\ORM\ValidationResult;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Form used for editing a date stirng
|
* Form used for editing a date stirng
|
||||||
@ -403,8 +404,16 @@ class DateField extends TextField
|
|||||||
_t(
|
_t(
|
||||||
'DateField.VALIDDATEMINDATE',
|
'DateField.VALIDDATEMINDATE',
|
||||||
"Your date has to be newer or matching the minimum allowed date ({date})",
|
"Your date has to be newer or matching the minimum allowed date ({date})",
|
||||||
['date' => $this->internalToFrontend($min)]
|
[
|
||||||
|
'date' => sprintf(
|
||||||
|
'<time datetime="%s">%s</time>',
|
||||||
|
$min,
|
||||||
|
$this->internalToFrontend($min)
|
||||||
)
|
)
|
||||||
|
]
|
||||||
|
),
|
||||||
|
ValidationResult::TYPE_ERROR,
|
||||||
|
ValidationResult::CAST_HTML
|
||||||
);
|
);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -420,8 +429,16 @@ class DateField extends TextField
|
|||||||
_t(
|
_t(
|
||||||
'DateField.VALIDDATEMAXDATE',
|
'DateField.VALIDDATEMAXDATE',
|
||||||
"Your date has to be older or matching the maximum allowed date ({date})",
|
"Your date has to be older or matching the maximum allowed date ({date})",
|
||||||
['date' => $this->internalToFrontend($max)]
|
[
|
||||||
|
'date' => sprintf(
|
||||||
|
'<time datetime="%s">%s</time>',
|
||||||
|
$max,
|
||||||
|
$this->internalToFrontend($max)
|
||||||
)
|
)
|
||||||
|
]
|
||||||
|
),
|
||||||
|
ValidationResult::TYPE_ERROR,
|
||||||
|
ValidationResult::CAST_HTML
|
||||||
);
|
);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -6,6 +6,7 @@ use IntlDateFormatter;
|
|||||||
use InvalidArgumentException;
|
use InvalidArgumentException;
|
||||||
use SilverStripe\i18n\i18n;
|
use SilverStripe\i18n\i18n;
|
||||||
use SilverStripe\ORM\FieldType\DBDatetime;
|
use SilverStripe\ORM\FieldType\DBDatetime;
|
||||||
|
use SilverStripe\ORM\ValidationResult;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Form field used for editing date time strings.
|
* Form field used for editing date time strings.
|
||||||
@ -586,8 +587,16 @@ class DatetimeField extends TextField
|
|||||||
_t(
|
_t(
|
||||||
'DatetimeField.VALIDDATETIMEMINDATE',
|
'DatetimeField.VALIDDATETIMEMINDATE',
|
||||||
"Your date has to be newer or matching the minimum allowed date and time ({datetime})",
|
"Your date has to be newer or matching the minimum allowed date and time ({datetime})",
|
||||||
['datetime' => $this->internalToFrontend($min)]
|
[
|
||||||
|
'datetime' => sprintf(
|
||||||
|
'<time datetime="%s">%s</time>',
|
||||||
|
$min,
|
||||||
|
$this->internalToFrontend($min)
|
||||||
)
|
)
|
||||||
|
]
|
||||||
|
),
|
||||||
|
ValidationResult::TYPE_ERROR,
|
||||||
|
ValidationResult::CAST_HTML
|
||||||
);
|
);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -603,8 +612,16 @@ class DatetimeField extends TextField
|
|||||||
_t(
|
_t(
|
||||||
'DatetimeField.VALIDDATEMAXDATETIME',
|
'DatetimeField.VALIDDATEMAXDATETIME',
|
||||||
"Your date has to be older or matching the maximum allowed date and time ({datetime})",
|
"Your date has to be older or matching the maximum allowed date and time ({datetime})",
|
||||||
['datetime' => $this->internalToFrontend($max)]
|
[
|
||||||
|
'datetime' => sprintf(
|
||||||
|
'<time datetime="%s">%s</time>',
|
||||||
|
$max,
|
||||||
|
$this->internalToFrontend($max)
|
||||||
)
|
)
|
||||||
|
]
|
||||||
|
),
|
||||||
|
ValidationResult::TYPE_ERROR,
|
||||||
|
ValidationResult::CAST_HTML
|
||||||
);
|
);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user