diff --git a/core/lib/Drupal/Core/Entity/Plugin/EntityReferenceSelection/DefaultSelection.php b/core/lib/Drupal/Core/Entity/Plugin/EntityReferenceSelection/DefaultSelection.php index 2764866..424218a 100644 --- a/core/lib/Drupal/Core/Entity/Plugin/EntityReferenceSelection/DefaultSelection.php +++ b/core/lib/Drupal/Core/Entity/Plugin/EntityReferenceSelection/DefaultSelection.php @@ -100,6 +100,7 @@ public function buildConfigurationForm(array $form, FormStateInterface $form_sta '#element_validate' => [[get_class($this), 'elementValidateFilter']], '#ajax' => TRUE, '#limit_validation_errors' => [], + '#weight' => -5, ]; $form['target_bundles_update'] = [ @@ -142,6 +143,11 @@ public function buildConfigurationForm(array $form, FormStateInterface $form_sta } } + $form['sort'] = [ + '#type' => 'container', + '#weight' => -4, + ]; + $form['sort']['field'] = [ '#type' => 'select', '#title' => $this->t('Sort by'), diff --git a/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/EntityReferenceItem.php b/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/EntityReferenceItem.php index 70f9dc9..5993156 100644 --- a/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/EntityReferenceItem.php +++ b/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/EntityReferenceItem.php @@ -345,7 +345,7 @@ public function fieldSettingsForm(array $form, FormStateInterface $form_state) { ]; $form['handler'] = [ '#type' => 'details', - '#title' => t('Reference type'), + '#title' => t('Reference options'), '#open' => TRUE, '#tree' => TRUE, '#process' => [[get_class($this), 'formProcessMergeParent']], diff --git a/core/modules/field/field.module b/core/modules/field/field.module index 14340b8..6df9be1 100644 --- a/core/modules/field/field.module +++ b/core/modules/field/field.module @@ -335,6 +335,29 @@ function field_form_config_admin_import_form_alter(&$form, FormStateInterface $f } /** + * Implements hook_form_FORM_ID_alter(). + */ +function field_form_field_config_edit_form_alter(array &$form, FormStateInterface $form_state) { + $field = $form_state->getFormObject()->getEntity(); + + // Only act on entity_reference fields. + /** @var \Drupal\Core\Field\FieldTypePluginManagerInterface $field_type_manager */ + $field_type_manager = \Drupal::service('plugin.manager.field.field_type'); + $class = $field_type_manager->getPluginClass($field->getType()); + $item_class = 'Drupal\Core\Field\Plugin\Field\FieldType\EntityReferenceItem'; + if ($class !== $item_class && !is_subclass_of($class, $item_class)) { + return; + } + + // Move the field type settings container all the way to the top of the page, + // only after the label field. + $label_weight = isset($form['label']['#weight']) ? $form['label']['#weight'] : FALSE; + if (!empty($form['settings']) && $label_weight !== FALSE) { + $form['settings']['#weight'] = $label_weight + 0.001; + } +} + +/** * Implements hook_ENTITY_TYPE_update() for 'field_storage_config'. * * Reset the field handler settings, when the storage target_type is changed on