diff --git a/composer.json b/composer.json index bdc268f574501ab22b3919bfa8a49e13643b37a1..7c9a9c52699c533df10bdc61949e7c6f7ae64bac 100644 --- a/composer.json +++ b/composer.json @@ -129,7 +129,7 @@ "drupal/google_tag": "1.4", "drupal/honeypot": "1.30", "drupal/image_popup": "1.1", - "drupal/inline_entity_form": "1.0-rc6", + "drupal/inline_entity_form": "1.0-rc7", "drupal/libraries": "3.0.0-alpha1", "drupal/link_attributes": "1.10", "drupal/linkit": "5.0-beta11", diff --git a/composer.lock b/composer.lock index c2e27f1d56567785b41f71c6bedd6ca247709252..2040c8bfb6ff36c41ab0070891809ad141ced08f 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "6a15808ea43555a7d6d68dd3386988f6", + "content-hash": "122a465332e5ebd24a8736de41a524fb", "packages": [ { "name": "alchemy/zippy", @@ -5321,17 +5321,17 @@ }, { "name": "drupal/inline_entity_form", - "version": "1.0.0-rc6", + "version": "1.0.0-rc7", "source": { "type": "git", "url": "https://git.drupalcode.org/project/inline_entity_form.git", - "reference": "8.x-1.0-rc6" + "reference": "8.x-1.0-rc7" }, "dist": { "type": "zip", - "url": "https://ftp.drupal.org/files/projects/inline_entity_form-8.x-1.0-rc6.zip", - "reference": "8.x-1.0-rc6", - "shasum": "9f7508f4cb88d5e7869c81b20b44d89bc1689fad" + "url": "https://ftp.drupal.org/files/projects/inline_entity_form-8.x-1.0-rc7.zip", + "reference": "8.x-1.0-rc7", + "shasum": "a11e59a8f3632728165170e9337cec9bc8eab870" }, "require": { "drupal/core": "^8.7.7 || ^9" @@ -5342,8 +5342,8 @@ "type": "drupal-module", "extra": { "drupal": { - "version": "8.x-1.0-rc6", - "datestamp": "1589280847", + "version": "8.x-1.0-rc7", + "datestamp": "1595545223", "security-coverage": { "status": "not-covered", "message": "RC releases are not covered by Drupal security advisories." diff --git a/vendor/composer/installed.json b/vendor/composer/installed.json index fdf14cf5db3d9f836dea09faf11a73b01d8d3f1f..8d97a4fce0ca5f36c5283aea5863dc3e6a8a1003 100644 --- a/vendor/composer/installed.json +++ b/vendor/composer/installed.json @@ -5481,18 +5481,18 @@ }, { "name": "drupal/inline_entity_form", - "version": "1.0.0-rc6", - "version_normalized": "1.0.0.0-RC6", + "version": "1.0.0-rc7", + "version_normalized": "1.0.0.0-RC7", "source": { "type": "git", "url": "https://git.drupalcode.org/project/inline_entity_form.git", - "reference": "8.x-1.0-rc6" + "reference": "8.x-1.0-rc7" }, "dist": { "type": "zip", - "url": "https://ftp.drupal.org/files/projects/inline_entity_form-8.x-1.0-rc6.zip", - "reference": "8.x-1.0-rc6", - "shasum": "9f7508f4cb88d5e7869c81b20b44d89bc1689fad" + "url": "https://ftp.drupal.org/files/projects/inline_entity_form-8.x-1.0-rc7.zip", + "reference": "8.x-1.0-rc7", + "shasum": "a11e59a8f3632728165170e9337cec9bc8eab870" }, "require": { "drupal/core": "^8.7.7 || ^9" @@ -5503,8 +5503,8 @@ "type": "drupal-module", "extra": { "drupal": { - "version": "8.x-1.0-rc6", - "datestamp": "1589280847", + "version": "8.x-1.0-rc7", + "datestamp": "1595545223", "security-coverage": { "status": "not-covered", "message": "RC releases are not covered by Drupal security advisories." diff --git a/web/modules/inline_entity_form/inline_entity_form.info.yml b/web/modules/inline_entity_form/inline_entity_form.info.yml index 5958676d6f4298b355c0bb242ac05628439bd386..666ff00c9c7068a419d2347cf8ff1525c4f30763 100644 --- a/web/modules/inline_entity_form/inline_entity_form.info.yml +++ b/web/modules/inline_entity_form/inline_entity_form.info.yml @@ -4,7 +4,7 @@ type: module package: Fields core_version_requirement: ^8.7.7 || ^9 -# Information added by Drupal.org packaging script on 2020-05-12 -version: '8.x-1.0-rc6' +# Information added by Drupal.org packaging script on 2020-07-23 +version: '8.x-1.0-rc7' project: 'inline_entity_form' -datestamp: 1589280849 +datestamp: 1595545225 diff --git a/web/modules/inline_entity_form/inline_entity_form.module b/web/modules/inline_entity_form/inline_entity_form.module index 7e1e50803e25e4851b2264c2ad599baab4d906e3..d535200ce717b0a883830e1d301c4dd12167037e 100644 --- a/web/modules/inline_entity_form/inline_entity_form.module +++ b/web/modules/inline_entity_form/inline_entity_form.module @@ -51,7 +51,6 @@ function inline_entity_form_theme() { return [ 'inline_entity_form_entity_table' => [ 'render element' => 'form', - 'function' => 'theme_inline_entity_form_entity_table', ], ]; } @@ -317,13 +316,15 @@ function inline_entity_form_get_element($form, FormStateInterface $form_state) { } /** - * Themes the table showing existing entity references in the widget. + * Prepares variables for inline_entity_form_entity_table form templates. + * + * Default template: inline-entity-form-entity-table.html.twig. * * @param array $variables - * Contains the form element data from $element['entities']. + * An associative array containing: + * - form: A render element representing the form. */ -function theme_inline_entity_form_entity_table($variables) { - $renderer = \Drupal::service('renderer'); +function template_preprocess_inline_entity_form_entity_table(array &$variables) { $form = $variables['form']; $entity_type = $form['#entity_type']; @@ -359,8 +360,8 @@ function theme_inline_entity_form_entity_table($variables) { $row_classes = ['ief-row-entity']; $cells = []; if ($has_tabledrag) { - $cells[] = ['data' => '', 'class' => ['ief-tabledrag-handle']]; - $cells[] = $renderer->render($form[$key]['delta']); + $cells[] = ['data' => ['#plain_text' => ''], '#wrapper_attributes' => ['class' => ['ief-tabledrag-handle']]]; + $cells[] = ['data' => $form[$key]['delta']]; $row_classes[] = 'draggable'; } // Add a special class to rows that have a form underneath, to allow @@ -371,7 +372,7 @@ function theme_inline_entity_form_entity_table($variables) { foreach ($fields as $field_name => $field) { if ($field['type'] == 'label') { - $data = $variables['form'][$key]['#label']; + $data = ['#markup' => $variables['form'][$key]['#label']]; } elseif ($field['type'] == 'field' && $entity->hasField($field_name)) { $display_options = ['label' => 'hidden']; @@ -390,24 +391,30 @@ function theme_inline_entity_form_entity_table($variables) { } $data = call_user_func_array($field['callback'], $arguments); + + // Backward compatibility for callbacks that just provide a string not an array. + if(!is_array($data)) { + $data = ['#markup' => $data]; + } } else { - $data = t('N/A'); + $data = ['#markup' => t('N/A')]; } - $cells[] = ['data' => $data, 'class' => ['inline-entity-form-' . $entity_type . '-' . $field_name]]; + $cells[$field_name] = array_merge($data, ['#wrapper_attributes' => ['class' => ['inline-entity-form-' . $entity_type . '-' . $field_name]]]); } - // Add the buttons belonging to the "Operations" column. - $cells[] = $renderer->render($form[$key]['actions']); + // Add the buttons belonging to the "Operations" column, when entity is not + // being displayed as a form. + if (empty($form[$key]['form'])) { + $cells['actions'] = $form[$key]['actions']; + } // Create the row. - $rows[] = ['data' => $cells, 'class' => $row_classes]; + $rows[] = $cells + ['#attributes' => ['class' => $row_classes]]; // If the current entity array specifies a form, output it in the next row. if (!empty($form[$key]['form'])) { - $row = [ - ['data' => $renderer->render($form[$key]['form']), 'colspan' => count($fields) + 1], - ]; - $rows[] = ['data' => $row, 'class' => ['ief-row-form'], 'no_striping' => TRUE]; + $row[] = $form[$key]['form'] + ['#wrapper_attributes' => ['colspan' => count($fields) + 1]]; + $rows[] = $row + ['#attributes' => ['class' => ['ief-row-form'], 'no_striping' => TRUE]]; } } @@ -423,17 +430,14 @@ function theme_inline_entity_form_entity_table($variables) { ]; } - $table = [ + $variables['table'] = [ '#type' => 'table', '#header' => $header, - '#rows' => $rows, '#attributes' => [ 'id' => 'ief-entity-table-' . $form['#id'], 'class' => ['ief-entity-table'], ], '#tabledrag' => $tabledrag, - ]; - - return $renderer->render($table); + ] + $rows; } } diff --git a/web/modules/inline_entity_form/src/InlineFormInterface.php b/web/modules/inline_entity_form/src/InlineFormInterface.php index f7b0b2a552cf7186a1931a803616b8d7072660db..5bbd02dba8453b6a178206ea1a96d3298004a526 100644 --- a/web/modules/inline_entity_form/src/InlineFormInterface.php +++ b/web/modules/inline_entity_form/src/InlineFormInterface.php @@ -60,7 +60,8 @@ public function getEntityLabel(EntityInterface $entity); * - 'field': A field value from the entity. The name of the field is * given by the key in this array. * - 'callback': A callback, given by the 'callback' property. - * See theme_inline_entity_form_entity_table() for the handling of these. + * @see template_preprocess_inline_entity_form_entity_table() for the + * handling of these. * - label: the title of the table field's column in the IEF table. * - weight: the sort order of the column in the IEF table. * - display_options: (optional) used for 'field' type table columns, an diff --git a/web/modules/inline_entity_form/src/Plugin/Field/FieldWidget/InlineEntityFormComplex.php b/web/modules/inline_entity_form/src/Plugin/Field/FieldWidget/InlineEntityFormComplex.php index a4b2c306b8ec9d6c5daa000a02f1c45972f93c14..39f1da583578e569b5e476336ab817b92f8a4251 100644 --- a/web/modules/inline_entity_form/src/Plugin/Field/FieldWidget/InlineEntityFormComplex.php +++ b/web/modules/inline_entity_form/src/Plugin/Field/FieldWidget/InlineEntityFormComplex.php @@ -279,7 +279,8 @@ public function formElement(FieldItemListInterface $items, $delta, array $elemen $weight_delta = max(ceil($entities_count * 1.2), 50); foreach ($entities as $key => $value) { - // Data used by theme_inline_entity_form_entity_table(). + // Data used by inline-entity-form-entity-table.html.twig. + // @see template_preprocess_inline_entity_form_entity_table() /** @var \Drupal\Core\Entity\EntityInterface $entity */ $entity = $value['entity']; $element['entities'][$key]['#label'] = $this->inlineFormHandler->getEntityLabel($value['entity']); diff --git a/web/modules/inline_entity_form/templates/inline-entity-form-entity-table.html.twig b/web/modules/inline_entity_form/templates/inline-entity-form-entity-table.html.twig new file mode 100644 index 0000000000000000000000000000000000000000..67c1718f895face04b358fc3175820906514593c --- /dev/null +++ b/web/modules/inline_entity_form/templates/inline-entity-form-entity-table.html.twig @@ -0,0 +1,15 @@ +{# +/** + * @file + * Default theme implementation for a theme's inline_entity_form_entity_table form. + * + * Available variables: + * - form: Form elements for the inline_entity_form_entity_table form. + * - table: The table of referenced entities. + * + * @see template_preprocess_inline_entity_form_entity_table() + * + * @ingroup themeable + */ +#} +{{ table }} diff --git a/web/modules/inline_entity_form/tests/modules/inline_entity_form_test/inline_entity_form_test.info.yml b/web/modules/inline_entity_form/tests/modules/inline_entity_form_test/inline_entity_form_test.info.yml index 254568bd5a6c6e5d5d628a4b543dc7bf87973336..fdf1e3544acf4a98cb8773c4ea02b115cc96a924 100644 --- a/web/modules/inline_entity_form/tests/modules/inline_entity_form_test/inline_entity_form_test.info.yml +++ b/web/modules/inline_entity_form/tests/modules/inline_entity_form_test/inline_entity_form_test.info.yml @@ -9,7 +9,7 @@ dependencies: - drupal:file - drupal:image -# Information added by Drupal.org packaging script on 2020-05-12 -version: '8.x-1.0-rc6' +# Information added by Drupal.org packaging script on 2020-07-23 +version: '8.x-1.0-rc7' project: 'inline_entity_form' -datestamp: 1589280849 +datestamp: 1595545225 diff --git a/web/modules/inline_entity_form/tests/modules/inline_entity_form_translation_test/inline_entity_form_translation_test.info.yml b/web/modules/inline_entity_form/tests/modules/inline_entity_form_translation_test/inline_entity_form_translation_test.info.yml index 8f46dfe35d24dd2c9cd624be009d12434e6e272e..372f1dd28011f506e2dd50cc1d7b8b4e7622da4a 100644 --- a/web/modules/inline_entity_form/tests/modules/inline_entity_form_translation_test/inline_entity_form_translation_test.info.yml +++ b/web/modules/inline_entity_form/tests/modules/inline_entity_form_translation_test/inline_entity_form_translation_test.info.yml @@ -8,7 +8,7 @@ dependencies: - drupal:language - drupal:content_translation -# Information added by Drupal.org packaging script on 2020-05-12 -version: '8.x-1.0-rc6' +# Information added by Drupal.org packaging script on 2020-07-23 +version: '8.x-1.0-rc7' project: 'inline_entity_form' -datestamp: 1589280849 +datestamp: 1595545225