Commit f6183952 authored by webchick's avatar webchick

Issue #2337653 by swentel: Fixed DraggableListBuilder should dynamically...

Issue #2337653 by swentel: Fixed DraggableListBuilder should dynamically calculate a delta for configuration entities weight field.
parent 35ca1eff
......@@ -118,11 +118,22 @@ public function buildForm(array $form, FormStateInterface $form_state) {
);
$this->entities = $this->load();
$delta = 10;
// Change the delta of the weight field if have more than 20 entities.
if (!empty($this->weightKey)) {
$count = count($this->entities);
if ($count > 20) {
$delta = ceil($count / 2);
}
}
foreach ($this->entities as $entity) {
$row = $this->buildRow($entity);
if (isset($row['label'])) {
$row['label'] = array('#markup' => $row['label']);
}
if (isset($row['weight'])) {
$row['weight']['#delta'] = $delta;
}
$form[$this->entitiesKey][$entity->id()] = $row;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment