diff --git a/core/lib/Drupal/Core/Entity/EntityFormController.php b/core/lib/Drupal/Core/Entity/EntityFormController.php index ceb09de..276ac34 100644 --- a/core/lib/Drupal/Core/Entity/EntityFormController.php +++ b/core/lib/Drupal/Core/Entity/EntityFormController.php @@ -212,12 +212,15 @@ public function processForm($element, $form_state, $form) { } } - // Hide extra fields. + // Hide or assign weights for extra fields. $extra_fields = field_info_extra_fields($this->entity->entityType(), $this->entity->bundle(), 'form'); foreach ($extra_fields as $extra_field => $info) { if (!$this->getFormDisplay($form_state)->getComponent($extra_field)) { $element[$extra_field]['#access'] = FALSE; } + else { + $element[$extra_field]['#weight'] = $info['weight']; + } } return $element; diff --git a/core/modules/field/lib/Drupal/field/FieldInfo.php b/core/modules/field/lib/Drupal/field/FieldInfo.php index 2639c25..a546411 100644 --- a/core/modules/field/lib/Drupal/field/FieldInfo.php +++ b/core/modules/field/lib/Drupal/field/FieldInfo.php @@ -543,7 +543,7 @@ public function getBundleExtraFields($entity_type, $bundle) { drupal_alter('field_extra_fields', $extra); // Merge in saved settings. if (isset($extra[$entity_type][$bundle])) { - $info = $this->prepareExtraFields($extra[$entity_type][$bundle], $entity_type, $bundle); + $info = $extra[$entity_type][$bundle] + array('form' => array(), 'display' => array()); } // Store in the 'static' and persistent caches. @@ -593,38 +593,4 @@ public function prepareInstance($instance, $field_type) { return $instance; } - /** - * Prepares 'extra fields' for the current run-time context. - * - * @param $extra_fields - * The array of extra fields, as collected in hook_field_extra_fields(). - * @param $entity_type - * The entity type. - * @param $bundle - * The bundle name. - * - * @return - * The list of extra fields completed for the current runtime context. - */ - public function prepareExtraFields($extra_fields, $entity_type, $bundle) { - $entity_type_info = entity_get_info($entity_type); - $bundle_settings = field_bundle_settings($entity_type, $bundle); - $extra_fields += array('form' => array(), 'display' => array()); - - $result = array(); - // Extra fields in forms. - foreach ($extra_fields['form'] as $name => $field_data) { - $settings = isset($bundle_settings['extra_fields']['form'][$name]) ? $bundle_settings['extra_fields']['form'][$name] : array(); - if (isset($settings['weight'])) { - $field_data['weight'] = $settings['weight']; - } - $result['form'][$name] = $field_data; - } - - // Extra fields in displayed entities. - $result['display'] = $extra_fields['display']; - - return $result; - } - }