commit 1c82b3ee7862350c4e3b26a65ace87d9a5be20f2 Author: Joel Pittet Date: Thu Oct 22 16:22:07 2015 -0700 fix diff --git a/core/modules/field_ui/field_ui.module b/core/modules/field_ui/field_ui.module index 9ac9d90..56375fc 100644 --- a/core/modules/field_ui/field_ui.module +++ b/core/modules/field_ui/field_ui.module @@ -218,14 +218,14 @@ function field_ui_entity_form_mode_delete(EntityFormModeInterface $form_mode) { } /** - * Returns HTML for Field UI overview tables. + * Prepares variables for field UI overview table templates. * - * @param $variables + * Default template: field-ui-table.html.twig. + * + * @param array $variables * An associative array containing: * - elements: An associative array containing a Form API structure to be * rendered as a table. - * - * @ingroup themeable */ function template_preprocess_field_ui_table(&$variables) { template_preprocess_table($variables); diff --git a/core/modules/field_ui/src/Element/FieldUiTable.php b/core/modules/field_ui/src/Element/FieldUiTable.php index 48ebda4..18e657f 100644 --- a/core/modules/field_ui/src/Element/FieldUiTable.php +++ b/core/modules/field_ui/src/Element/FieldUiTable.php @@ -26,7 +26,7 @@ public function getInfo() { $info['#regions'] = ['' => []]; $info['#theme'] = 'field_ui_table'; // Prepend FieldUiTable's prerender. - array_unshift($info['#pre_render'], [$this, 'tablePreRender']); + array_unshift($info['#pre_render'], [$this, 'tablePreRender'], [$this, 'preRenderRegionRows']); return $info; } @@ -124,6 +124,18 @@ public static function tablePreRender($elements) { } } + return $elements; + } + + /** + * Performs pre-render to move #regions to rows. + * + * @param array $elements + * + * @return array + * The $element with prepared variables ready for field-ui-table.html.twig. + */ + public static function preRenderRegionRows($elements) { // Determine the colspan to use for region rows, by checking the number of // columns in the headers. $columns_count = 0; @@ -199,12 +211,11 @@ public static function tablePreRender($elements) { /** * Determines the rendering order of an array representing a tree. * - * Callback for array_reduce() within - * \Drupal\field_ui\Form\EntityDisplayFormBase::tablePreRender(). + * Callback for array_reduce() within ::tablePreRender(). * * @param mixed $array - * Holds the return value of the previous iteration; in the case of the - * first iteration it instead holds the value of initial. + * Holds the return value of the previous iteration; in the case of the + * first iteration it instead holds the value of the initial array. * @param mixed $a * Holds the value of the current iteration. * diff --git a/core/modules/field_ui/src/Form/EntityDisplayFormBase.php b/core/modules/field_ui/src/Form/EntityDisplayFormBase.php index d828093..e0b622a 100644 --- a/core/modules/field_ui/src/Form/EntityDisplayFormBase.php +++ b/core/modules/field_ui/src/Form/EntityDisplayFormBase.php @@ -19,6 +19,7 @@ use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Render\Element; use Drupal\Core\Routing\RouteMatchInterface; +use Drupal\field_ui\Element\FieldUiTable; use Drupal\field_ui\FieldUI; /** @@ -673,6 +674,39 @@ public function multistepAjax($form, FormStateInterface $form_state) { } /** + * Performs pre-render tasks on field_ui_table elements. + * + * @param array $elements + * A structured array containing two sub-levels of elements. Properties + * used: + * - #tabledrag: The value is a list of $options arrays that are passed to + * drupal_attach_tabledrag(). The HTML ID of the table is added to each + * $options array. + * + * @return array + * + * @see drupal_render() + * @see \Drupal\Core\Render\Element\Table::preRenderTable() + * + * @deprecated in Drupal 8.0.0, will be removed before Drupal 9.0.0. + */ + public function tablePreRender($elements) { + return FieldUiTable::tablePreRender($elements); + } + + /** + * Determines the rendering order of an array representing a tree. + * + * Callback for array_reduce() within + * \Drupal\field_ui\Form\EntityDisplayFormBase::tablePreRender(). + * + * @deprecated in Drupal 8.0.0, will be removed before Drupal 9.0.0. + */ + public function reduceOrder($array, $a) { + return FieldUiTable::reduceOrder($array, $a); + } + + /** * Returns the extra fields of the entity type and bundle used by this form. * * @return array diff --git a/core/modules/field_ui/templates/field-ui-table.html.twig b/core/modules/field_ui/templates/field-ui-table.html.twig index 698f3f4..f7ff026 100644 --- a/core/modules/field_ui/templates/field-ui-table.html.twig +++ b/core/modules/field_ui/templates/field-ui-table.html.twig @@ -36,7 +36,7 @@ * - no_striping: A boolean indicating that the row should receive no striping. * - header_columns: The number of columns in the header. * - * @see template_preprocess_table() + * @see template_preprocess_field_ui_table() * * @ingroup themeable */