Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
drupal
Manage
Activity
Members
Labels
Plan
Wiki
Custom issue tracker
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Model registry
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
project
drupal
Merge requests
!1976
Issue
#3269890
: #date_year_range is not validated server-side
Code
Review changes
Check out branch
Download
Patches
Plain diff
Open
Issue
#3269890
: #date_year_range is not validated server-side
issue/drupal-3269890:3269890-dateyearrange-is-not
into
11.x
Overview
2
Commits
7
Pipelines
7
Changes
2
All threads resolved!
Show all comments
Open
Pierre Rudloff
requested to merge
issue/drupal-3269890:3269890-dateyearrange-is-not
into
11.x
3 years ago
Overview
2
Commits
7
Pipelines
7
Changes
2
All threads resolved!
Show all comments
Expand
0
0
Merge request reports
Compare
11.x
version 8
6469aec5
4 weeks ago
version 7
77a3eca1
2 months ago
version 6
76c4eb6d
2 months ago
version 5
8afe7ab3
2 months ago
version 4
b6f41cbc
2 months ago
version 3
7cfd267a
2 months ago
version 2
90951234
2 months ago
version 1
90951234
3 years ago
11.x (HEAD)
and
latest version
latest version
772c3292
7 commits,
4 weeks ago
version 8
6469aec5
6 commits,
4 weeks ago
version 7
77a3eca1
6 commits,
2 months ago
version 6
76c4eb6d
5 commits,
2 months ago
version 5
8afe7ab3
4 commits,
2 months ago
version 4
b6f41cbc
3 commits,
2 months ago
version 3
7cfd267a
1 commit,
2 months ago
version 2
90951234
272 commits,
2 months ago
version 1
90951234
1 commit,
3 years ago
2 files
+
60
−
1
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
Files
2
Search (e.g. *.vue) (Ctrl+P)
core/lib/Drupal/Core/Datetime/Element/Datetime.php
+
15
−
1
Options
@@ -389,7 +389,21 @@ public static function validateDatetime(&$element, FormStateInterface $form_stat
// If the date is valid, set it.
$date
=
$input
[
'object'
];
if
(
$date
instanceof
DrupalDateTime
&&
!
$date
->
hasErrors
())
{
$form_state
->
setValueForElement
(
$element
,
$date
);
$range
=
self
::
datetimeRangeYears
(
$element
[
'#date_year_range'
]);
$min
=
DrupalDateTime
::
createFromArray
([
'year'
=>
$range
[
0
]],
$date
->
getTimezone
());
$max
=
DrupalDateTime
::
createFromArray
([
'year'
=>
$range
[
1
]
+
1
],
$date
->
getTimezone
());
// Check if the date is in the allowed year range.
if
(
$date
<
$min
||
$date
>=
$max
)
{
$form_state
->
setError
(
$element
,
t
(
'The %field date is invalid. Date should be in the %min-%max year range.'
,
[
'%field'
=>
$title
,
'%min'
=>
$range
[
0
],
'%max'
=>
$range
[
1
]])
);
}
else
{
$form_state
->
setValueForElement
(
$element
,
$date
);
}
}
// If the date is invalid, set an error. A reminder of the required
// format in the message provides a good UX.
Loading