diff --git a/core/lib/Drupal/Core/Config/Entity/DraggableListController.php b/core/lib/Drupal/Core/Config/Entity/DraggableListController.php
index bbd2c87..6f1a0af 100644
--- a/core/lib/Drupal/Core/Config/Entity/DraggableListController.php
+++ b/core/lib/Drupal/Core/Config/Entity/DraggableListController.php
@@ -18,6 +18,13 @@
abstract class DraggableListController extends ConfigEntityListController implements FormInterface {
/**
+ * The key to use for the form element containing the entities.
+ *
+ * @var string
+ */
+ protected $entitiesKey = 'entities';
+
+ /**
* Name of the entity's weight field or FALSE if no field is provided.
*
* @var string|bool
@@ -82,7 +89,7 @@ public function render() {
* {@inheritdoc}
*/
public function buildForm(array $form, array &$form_state) {
- $form['entities'] = array(
+ $form[$this->entitiesKey] = array(
'#type' => 'table',
'#header' => $this->buildHeader(),
'#empty' => t('There is no @label yet.', array('@label' => $this->entityInfo['label'])),
@@ -91,15 +98,12 @@ public function buildForm(array $form, array &$form_state) {
),
);
- // Save header's order of columns for sorting data-rows.
- $header_sort = array_flip(array_keys($form['entities']['#header']));
foreach ($this->load() as $entity) {
$row = $this->buildRow($entity);
if (isset($row['label'])) {
$row['label'] = array('#markup' => $row['label']);
}
- // Sort row columns by header's order.
- $form['entities'][$entity->id()] = array_merge($header_sort, $row);
+ $form[$this->entitiesKey][$entity->id()] = $row;
}
$form['actions']['#type'] = 'actions';
@@ -123,7 +127,7 @@ public function validateForm(array &$form, array &$form_state) {
* {@inheritdoc}
*/
public function submitForm(array &$form, array &$form_state) {
- $values = $form_state['values']['entities'];
+ $values = $form_state['values'][$this->entitiesKey];
$entities = $this->storage->loadMultiple(array_keys($values));
foreach ($values as $id => $value) {
if (isset($entities[$id]) && $entities[$id]->get($this->weightKey) != $value['weight']) {
diff --git a/core/modules/editor/editor.module b/core/modules/editor/editor.module
index 998f5ad..e9a44f0 100644
--- a/core/modules/editor/editor.module
+++ b/core/modules/editor/editor.module
@@ -156,19 +156,19 @@ function editor_menu() {
function editor_form_filter_admin_overview_alter(&$form, $form_state) {
// @todo Cleanup column injection: http://drupal.org/node/1876718
// Splice in the column for "Text editor" into the header.
- $position = array_search('name', $form['entities']['#header']) + 1;
- $start = array_splice($form['entities']['#header'], 0, $position, array('editor' => t('Text editor')));
- $form['entities']['#header'] = array_merge($start, $form['entities']['#header']);
+ $position = array_search('name', $form['formats']['#header']) + 1;
+ $start = array_splice($form['formats']['#header'], 0, $position, array('editor' => t('Text editor')));
+ $form['formats']['#header'] = array_merge($start, $form['formats']['#header']);
// Then splice in the name of each text editor for each text format.
$editors = Drupal::service('plugin.manager.editor')->getDefinitions();
- foreach (element_children($form['entities']) as $format_id) {
+ foreach (element_children($form['formats']) as $format_id) {
$editor = editor_load($format_id);
$editor_name = ($editor && isset($editors[$editor->editor])) ? $editors[$editor->editor]['label'] : drupal_placeholder('—');
$editor_column['editor'] = array('#markup' => $editor_name);
- $position = array_search('name', array_keys($form['entities'][$format_id])) + 1;
- $start = array_splice($form['entities'][$format_id], 0, $position, $editor_column);
- $form['entities'][$format_id] = array_merge($start, $form['entities'][$format_id]);
+ $position = array_search('name', array_keys($form['formats'][$format_id])) + 1;
+ $start = array_splice($form['formats'][$format_id], 0, $position, $editor_column);
+ $form['formats'][$format_id] = array_merge($start, $form['formats'][$format_id]);
}
}
diff --git a/core/modules/filter/lib/Drupal/filter/FilterFormatListController.php b/core/modules/filter/lib/Drupal/filter/FilterFormatListController.php
index 0209bb5..098aa7d 100644
--- a/core/modules/filter/lib/Drupal/filter/FilterFormatListController.php
+++ b/core/modules/filter/lib/Drupal/filter/FilterFormatListController.php
@@ -22,6 +22,11 @@
class FilterFormatListController extends DraggableListController implements EntityControllerInterface {
/**
+ * {@inheritdoc}
+ */
+ protected $entitiesKey = 'formats';
+
+ /**
* The config factory service.
*
* @var \Drupal\Core\Config\ConfigFactory
diff --git a/core/modules/language/lib/Drupal/language/LanguageListController.php b/core/modules/language/lib/Drupal/language/LanguageListController.php
index d1ebd24..17e6b17 100644
--- a/core/modules/language/lib/Drupal/language/LanguageListController.php
+++ b/core/modules/language/lib/Drupal/language/LanguageListController.php
@@ -17,6 +17,11 @@ class LanguageListController extends DraggableListController {
/**
* {@inheritdoc}
*/
+ protected $entitiesKey = 'languages';
+
+ /**
+ * {@inheritdoc}
+ */
public function load() {
$entities = $this->storage->loadByProperties(array('locked' => '0'));
uasort($entities, array($this->entityInfo['class'], 'sort'));
diff --git a/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/VocabularyTest.php b/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/VocabularyTest.php
index faed1a6..b5e0b77 100644
--- a/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/VocabularyTest.php
+++ b/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/VocabularyTest.php
@@ -90,7 +90,7 @@ function testTaxonomyAdminChangingWeights() {
foreach ($vocabularies as $key => $vocabulary) {
$weight = -$vocabulary->weight;
$vocabularies[$key]->weight = $weight;
- $edit['entities[' . $key . '][weight]'] = $weight;
+ $edit['vocabularies[' . $key . '][weight]'] = $weight;
}
// Saving the new weights via the interface.
$this->drupalPost('admin/structure/taxonomy', $edit, t('Save'));
diff --git a/core/modules/taxonomy/lib/Drupal/taxonomy/VocabularyListController.php b/core/modules/taxonomy/lib/Drupal/taxonomy/VocabularyListController.php
index 2513809..f5b6083 100644
--- a/core/modules/taxonomy/lib/Drupal/taxonomy/VocabularyListController.php
+++ b/core/modules/taxonomy/lib/Drupal/taxonomy/VocabularyListController.php
@@ -9,6 +9,7 @@
use Drupal\Core\Config\Entity\DraggableListController;
use Drupal\Core\Entity\EntityInterface;
+
/**
* Provides a listing of vocabularies.
*/
@@ -17,6 +18,11 @@ class VocabularyListController extends DraggableListController {
/**
* {@inheritdoc}
*/
+ protected $entitiesKey = 'vocabularies';
+
+ /**
+ * {@inheritdoc}
+ */
public function getFormID() {
return 'taxonomy_overview_vocabularies';
}
@@ -72,14 +78,13 @@ public function buildRow(EntityInterface $entity) {
*/
public function render() {
$entities = $this->load();
- // Creates a form for manipulating vocabulary weights if more then one
- // vocabulary exists.
- $build = parent::render();
+ // If there are not multiple vocabularies, disable dragging by unsetting the
+ // weight key.
if (count($entities) <= 1) {
- // Unset weight key to use render.
unset($this->weightKey);
- $build['#empty'] = t('No vocabularies available. Add vocabulary.', array('@link' => url('admin/structure/taxonomy/add')));
}
+ $build = parent::render();
+ $build['#empty'] = t('No vocabularies available. Add vocabulary.', array('@link' => url('admin/structure/taxonomy/add')));
return $build;
}