function DraggableListBuilder::submitForm

1 method overrides DraggableListBuilder::submitForm()
LanguageListBuilder::submitForm in core/modules/language/src/LanguageListBuilder.php
Form submission handler.

File

core/lib/Drupal/Core/Config/Entity/DraggableListBuilder.php, line 156

Class

DraggableListBuilder
Defines a class to build a draggable listing of configuration entities.

Namespace

Drupal\Core\Config\Entity

Code

public function submitForm(array &$form, FormStateInterface $form_state) {
  foreach ($form_state->getValue($this->entitiesKey) as $id => $value) {
    if (isset($this->entities[$id]) && $this->entities[$id]
      ->get($this->weightKey) != $value['weight']) {
      // Save entity only when its weight was changed.
      $this->entities[$id]
        ->set($this->weightKey, $value['weight']);
      $this->entities[$id]
        ->save();
    }
  }
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.