summaryrefslogtreecommitdiffstats
path: root/core/lib/Drupal/Core/Render
diff options
context:
space:
mode:
authorAlex Pott2018-03-01 10:14:13 (GMT)
committerAlex Pott2018-03-01 10:14:13 (GMT)
commitcf94492ee8673f2d0f62b760130ac8f1c623ae00 (patch)
treea544f54a0b95ed0e50dec0906c8a1a38ee6bacd3 /core/lib/Drupal/Core/Render
parent877e4a816983caa771f876ffe082b96a6fcd52eb (diff)
Issue #565220 by voleger, Yogesh Pawar, gpk, alexpott: Fix Weight form element behavior
Diffstat (limited to 'core/lib/Drupal/Core/Render')
-rw-r--r--core/lib/Drupal/Core/Render/Element/Weight.php5
1 files changed, 5 insertions, 0 deletions
diff --git a/core/lib/Drupal/Core/Render/Element/Weight.php b/core/lib/Drupal/Core/Render/Element/Weight.php
index 468290a..649de31 100644
--- a/core/lib/Drupal/Core/Render/Element/Weight.php
+++ b/core/lib/Drupal/Core/Render/Element/Weight.php
@@ -59,6 +59,11 @@ class Weight extends FormElement {
for ($n = (-1 * $element['#delta']); $n <= $element['#delta']; $n++) {
$weights[$n] = $n;
}
+ $default_value = (int) $element['#default_value'];
+ if (!isset($weights[$default_value])) {
+ $weights[$default_value] = $default_value;
+ ksort($weights);
+ }
$element['#options'] = $weights;
$element += $element_info_manager->getInfo('select');
}