diff --git a/composer.lock b/composer.lock index e29c9d3732119cb3e0b83ba329c380014fd2d318..0305c9ebc38addfbd647a9336f2b76a1b1cb73f7 100644 --- a/composer.lock +++ b/composer.lock @@ -4649,20 +4649,20 @@ }, { "name": "drupal/field_group", - "version": "3.0.0-rc1", + "version": "3.0.0", "source": { "type": "git", "url": "https://git.drupalcode.org/project/field_group.git", - "reference": "8.x-3.0-rc1" + "reference": "8.x-3.0" }, "dist": { "type": "zip", - "url": "https://ftp.drupal.org/files/projects/field_group-8.x-3.0-rc1.zip", - "reference": "8.x-3.0-rc1", - "shasum": "e291b5468c834a344e9aa6cafd3a76171d473a22" + "url": "https://ftp.drupal.org/files/projects/field_group-8.x-3.0.zip", + "reference": "8.x-3.0", + "shasum": "8d87cdc4abc417aa4d411bffcaeb0a3ef1afa497" }, "require": { - "drupal/core": "*" + "drupal/core": "^8 || ^9" }, "type": "drupal-module", "extra": { @@ -4670,11 +4670,11 @@ "dev-3.x": "3.x-dev" }, "drupal": { - "version": "8.x-3.0-rc1", - "datestamp": "1558647185", + "version": "8.x-3.0", + "datestamp": "1580250787", "security-coverage": { - "status": "not-covered", - "message": "RC releases are not covered by Drupal security advisories." + "status": "covered", + "message": "Covered by Drupal's security advisory policy" } } }, @@ -4696,12 +4696,12 @@ "homepage": "https://www.drupal.org/user/591438" }, { - "name": "swentel", - "homepage": "https://www.drupal.org/user/107403" + "name": "nils.destoop", + "homepage": "https://www.drupal.org/user/361625" }, { - "name": "zuuperman", - "homepage": "https://www.drupal.org/user/361625" + "name": "swentel", + "homepage": "https://www.drupal.org/user/107403" } ], "description": "Provides the field_group module.", diff --git a/vendor/composer/installed.json b/vendor/composer/installed.json index 21d26439d78ccca4f7f07d0c1e3942f4aeea2b46..8f76effc178babd5d705d6585af1ea475d736ec8 100644 --- a/vendor/composer/installed.json +++ b/vendor/composer/installed.json @@ -4789,21 +4789,21 @@ }, { "name": "drupal/field_group", - "version": "3.0.0-rc1", - "version_normalized": "3.0.0.0-RC1", + "version": "3.0.0", + "version_normalized": "3.0.0.0", "source": { "type": "git", "url": "https://git.drupalcode.org/project/field_group.git", - "reference": "8.x-3.0-rc1" + "reference": "8.x-3.0" }, "dist": { "type": "zip", - "url": "https://ftp.drupal.org/files/projects/field_group-8.x-3.0-rc1.zip", - "reference": "8.x-3.0-rc1", - "shasum": "e291b5468c834a344e9aa6cafd3a76171d473a22" + "url": "https://ftp.drupal.org/files/projects/field_group-8.x-3.0.zip", + "reference": "8.x-3.0", + "shasum": "8d87cdc4abc417aa4d411bffcaeb0a3ef1afa497" }, "require": { - "drupal/core": "*" + "drupal/core": "^8 || ^9" }, "type": "drupal-module", "extra": { @@ -4811,11 +4811,11 @@ "dev-3.x": "3.x-dev" }, "drupal": { - "version": "8.x-3.0-rc1", - "datestamp": "1558647185", + "version": "8.x-3.0", + "datestamp": "1580250787", "security-coverage": { - "status": "not-covered", - "message": "RC releases are not covered by Drupal security advisories." + "status": "covered", + "message": "Covered by Drupal's security advisory policy" } } }, @@ -4838,12 +4838,12 @@ "homepage": "https://www.drupal.org/user/591438" }, { - "name": "swentel", - "homepage": "https://www.drupal.org/user/107403" + "name": "nils.destoop", + "homepage": "https://www.drupal.org/user/361625" }, { - "name": "zuuperman", - "homepage": "https://www.drupal.org/user/361625" + "name": "swentel", + "homepage": "https://www.drupal.org/user/107403" } ], "description": "Provides the field_group module.", diff --git a/web/modules/field_group/CHANGELOG.txt b/web/modules/field_group/CHANGELOG.txt index a9d603fd156e34596688906e2c409cc7c436f1a4..c73d2a03011d7e5730faaf77537c4d53e8829f30 100644 --- a/web/modules/field_group/CHANGELOG.txt +++ b/web/modules/field_group/CHANGELOG.txt @@ -1,3 +1,60 @@ +8.x-3.0-rc1, 2019-03-28 +----------------------- +- View Mode '_custom' should not go through the entity_display_build_alter. +- Fix deprecated methods. +- Temp remove the typehinting. +- Fatal error when creating a paragraph. +- Use mb_* functions instead of deprecated Unicode::* methods. +- Large amount of fields causes tab functionality to break. +- Field_group_theme_suggestions_alter notices. +- Horizontal tab content is wrapped by detail border. +- Syntax error in HorizontalTabs.php causes module installation to fail. +- Duplicated fields with field_group on referenced ECK entities. +- Horizontal tabs break keyboard navigation. +- Accordion Doesn't Open on Error. +- Create field_group.api.php for D8 version. +- Choose sensible default tab for horizontal tabs. +- Extend signature of field_group_form_process(). +- Migrated field groups all disabled. +- Empty fieldgroups are showing in forms. +- Missing hook_help. +- Missing UI for description text for field groups. +- Field groups default region should never be null. +- Revert "Issue #2991400 by DuaelFr: Field groups default region should never be null". +- Field groups default region should never be null. +- How to create horizontal tabs with 8.x-3.x ?. +- XSS patch horizontal-tabs.js. +- Allow modules to define form elements beneath field groups before they are created. +- Field_group_migrate.info.yml should not contain "version: VERSION". +- 2998205: Fix call to member function errors when the plugin was not found. +- PHP message: Error: Call to a member function process() on null. +- Set default values in migrate destinations plugins. +- D6 migration doesn't generate the migrations templates. +- Change package name of migrate sub-modules. +- Accordion/Default State doesn't do anything. +- Fix access check for empty groups. +- Fix config schema. +- Markup ID of each tab is not unique. +- Revert "Issue #2904577: Duplicate CSS ID confuses behat". +- Duplicate CSS ID confuses behat. +- The region part of entity view config isn't set for old installs. +- Remove extra param in call to field_group_info_groups. +- Update the processGroup implementations. +- Cannot declare class HtmlElement. +- Fix extending preRenderGroup. +- Coding standards. +- Remove helpers.inc. +- Invalid CSS ID for field group causes error. +- Add option to set group label classes for HTML element type. +- Fix migration tests. +- Fix migrate unit test + accordion. +- Getting d6_field_group plugin must define the source_module property Error When Using migrate-upgrade. +- Field groups are not compatible with field layout. +- Accordion items with children with errors not open. +- Accordion doesn't work. +- Fix syntax errors. +- Convert module to use short array syntax (new coding standard). + 8.3.0-beta1, 2017-11-10 ------------------- - JS error: Modernizr is not defined. diff --git a/web/modules/field_group/README.txt b/web/modules/field_group/README.txt index 6c7257081159a601f417b3fc02e2491df24e6b17..5a2a7ddb58849ca1726773481b81909464dbf5cc 100644 --- a/web/modules/field_group/README.txt +++ b/web/modules/field_group/README.txt @@ -1,6 +1,17 @@ +CONTENTS OF THIS FILE +--------------------- + + * Introduction + * Requirements + * Installation + * Configuration + * Maintainers + +INTRODUCTION +------------ History: - Field_group was originally written when drupal 7 was released. For drupal 6, the module is - located in the CCK module (http://drupal.org/project/cck). + Field_group was originally written when drupal 7 was released. For drupal 6, + the module is located in the CCK module (http://drupal.org/project/cck). As drupal core has a fields API drupal > 6, the field_group module is considered a contribution. @@ -28,40 +39,65 @@ Available group types: - Tabs (horizontal and vertical) - Accordions - Details (Use this if you want collapsible fieldsets) + - Details Sidebar To submit bug reports and feature suggestions, or to track changes: http://drupal.org/project/issues/field_group --- Configuration -- -1. You can configure the field groups for different displays like, in managed_form_display and managed_display of the entity type. -2. You can create different field groups under managed_form_display by adding a new group under "Add new group" label and the format the grouping using the desired formatter for displaying the same. +REQUIREMENTS +------------ +None. + +INSTALLATION +------------ +Install as you would normally install a contributed Drupal module. Visit: +https://www.drupal.org/documentation/install/modules-themes/modules-8 +for further information. + +CONFIGURATION +------------- +1. You can configure the field groups for different displays like, in +managed_form_display and managed_display of the entity type. +2. You can create different field groups under managed_form_display by +adding a new group under "Add new group" label and the format the +grouping using the desired formatter for displaying the same. 3. Same thing can be done in managed_display. -4. The field grouping done in managed display will be reflected on the view detail page of the entity, while that done in the managed_form_display will be -reflected in the add/edit form of the entity. +4. The field grouping done in managed display will be reflected on the +view detail page of the entity, while that done in the +managed_form_display will be reflected in the add/edit form of the entity. -- Create field groups -- This section explains how to create groups of fields according to the type chosen. - Fieldsets : This group of fields makes the internal content in a fieldset. - It is possible to add a title and a caption (which appears at the bottom of the fieldset). - - Details : Similar to Fieldsets. You can configure them to be open (normal fieldset) or collapsed. + It is possible to add a title and a caption (which appears at + the bottom of the fieldset). + - Details : Similar to Fieldsets. You can configure them to be open (normal + fieldset) or collapsed. + - Details Sidebar: Similar to Details. You can configure them to be open + (normal fieldset) or collapsed and move them in the sidebar on + the node form. - Html element : This fieldgroup renders the inner content in a HTML element. You can configure attributes and label element. -The following two groupings works differently because you must associate them with an other grouping. +The following two groupings works differently because you must associate them with +an other grouping. - Accordions : This group of fields makes the child groups as a jQuery accordion. - As a first step you must create an Accordions group. You can set a label and choose an effect. - Then you can create an Accordion Item as a child. This group can contain fields. + As a first step you must create an Accordions group. You can set a + label and choose an effect. Then you can create an Accordion + Item as a child. This group can contain fields. - Tabs : This fieldgroup renders child groups in its own tabs wrapper. - As a first step you must create an Tabs group. You can set choose if you want that your tabs are show horizontally or vertically. - Then, you can create Tab as a child and choose one to be open by default. This group can contain fields. + As a first step you must create an Tabs group. You can set + choose if you want that your tabs are show horizontally or vertically. + Then, you can create Tab as a child and choose one to be open by default. + This group can contain fields. For all groups, you can add id or classes. -You can also choose if you want to mark a group as required if one of his fields is require (except for Accordions and Tabs : you must passed by their children). - --- MAINTAINERS -- +You can also choose if you want to mark a group as required if one of his fields is +require (except for Accordions and Tabs : you must passed by their children). +MAINTAINERS +----------- stalski - http://drupal.org/user/322618 zuuperman - http://drupal.org/user/361625 swentel - http://drupal.org/user/107403 --- INSPIRATORS -- - +Inspirators: yched - http://drupal.org/user/39567 diff --git a/web/modules/field_group/composer.json b/web/modules/field_group/composer.json index 82d093184177acdc80697aa3dfbb7aa5b767ae4b..ac893ea5173ee11b7d19b7dd874e7586e91c28a4 100644 --- a/web/modules/field_group/composer.json +++ b/web/modules/field_group/composer.json @@ -4,5 +4,7 @@ "type": "drupal-module", "license": "GPL-2.0+", "minimum-stability": "dev", - "require": {} + "require": { + "drupal/core": "^8 || ^9" + } } diff --git a/web/modules/field_group/config/schema/field_group.entity_display.schema.yml b/web/modules/field_group/config/schema/field_group.entity_display.schema.yml index a9fe072ec4ea75b1419597c50d5e330e27c17b2b..2f859c6288befafdaa48378788646c6e7e50de4b 100644 --- a/web/modules/field_group/config/schema/field_group.entity_display.schema.yml +++ b/web/modules/field_group/config/schema/field_group.entity_display.schema.yml @@ -12,7 +12,7 @@ core.entity_view_display.*.*.*.third_party.field_group: - type: string label: 'The field name' label: - type: string + type: label label: Readable name of the group parent_name: type: string @@ -43,7 +43,7 @@ core.entity_form_display.*.*.*.third_party.field_group: - type: string label: 'The field name' label: - type: string + type: label label: Readable name of the group region: type: string diff --git a/web/modules/field_group/config/schema/field_group.field_group_formatter_plugin.schema.yml b/web/modules/field_group/config/schema/field_group.field_group_formatter_plugin.schema.yml index c897f4aac9c5cc103a05b5458e4fdfa9ae18c3a9..01154220dbfccde8292369b26dc3f03018a3db32 100644 --- a/web/modules/field_group/config/schema/field_group.field_group_formatter_plugin.schema.yml +++ b/web/modules/field_group/config/schema/field_group.field_group_formatter_plugin.schema.yml @@ -14,8 +14,8 @@ field_group.field_group_formatter_plugin.accordion_item: type: string label: 'Formatting of the item' description: - type: string - label: 'description of the item' + type: label + label: 'Description of the item' required_fields: type: boolean label: 'Mark for required fields' @@ -27,17 +27,28 @@ field_group.field_group_formatter_plugin.details: open: type: boolean label: 'Display element open by default.' + description: + type: text + label: 'Description of the element' required_fields: type: boolean label: 'Mark for required fields' +field_group.field_group_formatter_plugin.details_sidebar: + type: field_group.field_group_formatter_plugin.details + label: 'Mapping for the details sidebar formatter settings' + mapping: + weight: + type: integer + label: 'Weight' + field_group.field_group_formatter_plugin.fieldset: type: field_group.field_group_formatter_plugin.base label: 'Mapping for the fieldset formatter settings' mapping: description: - type: string - label: 'description of the item' + type: label + label: 'Description of the item' required_fields: type: boolean label: 'Mark for required fields' @@ -79,8 +90,8 @@ field_group.field_group_formatter_plugin.tab: type: string label: 'default state for the tab' description: - type: string - label: 'description of the tab' + type: label + label: 'Description of the tab' required_fields: type: boolean label: 'Mark for required fields' @@ -93,7 +104,7 @@ field_group.field_group_formatter_plugin.tabs: type: string label: 'default state for the tabs' description: - type: string + type: label label: 'description of the tabs' required_fields: type: boolean @@ -107,7 +118,7 @@ field_group.field_group_formatter_plugin.base: label: 'Mapping for the base formatter settings' mapping: label: - type: string + type: label label: 'Label of the fieldgroup' classes: type: string diff --git a/web/modules/field_group/contrib/field_group_migrate/field_group_migrate.info.yml b/web/modules/field_group/contrib/field_group_migrate/field_group_migrate.info.yml index 96ef3018cfa2657f5c3ba21f7212ca086e9e4b1e..f1a0fb93f4ff1b767d0d88cdc77bff84b6154ebd 100644 --- a/web/modules/field_group/contrib/field_group_migrate/field_group_migrate.info.yml +++ b/web/modules/field_group/contrib/field_group_migrate/field_group_migrate.info.yml @@ -2,12 +2,11 @@ name: 'Field Group Migrate' type: module description: 'Provides the ability to migrate field groups from D6/D7 to D8.' package: Migration -# core: 8.x +core: 8.x dependencies: - field_group:field_group -# Information added by Drupal.org packaging script on 2019-05-23 -version: '8.x-3.0-rc1' -core: '8.x' +# Information added by Drupal.org packaging script on 2020-01-28 +version: '8.x-3.0' project: 'field_group' -datestamp: 1558647188 +datestamp: 1580250789 diff --git a/web/modules/field_group/field_group.api.php b/web/modules/field_group/field_group.api.php index 0125f5b380f57d5449a63adb11d404b80713c19a..a81977953f016db9eacb91cc3758d1aa6d7fc0d8 100644 --- a/web/modules/field_group/field_group.api.php +++ b/web/modules/field_group/field_group.api.php @@ -65,21 +65,13 @@ function hook_field_group_pre_render_alter(array &$element, &$group, &$rendering } /** - * Alter the pre_rendered build of the form. + * Alter the pre_rendered build of the entity view. * * @param array $element * Group being rendered. */ function hook_field_group_build_pre_render_alter(array &$element) { - $form_id = $element['#form_id']; - if ($form_id == 'my_example_form' && isset($element['group_example'])) { - // Add form states to the field group. - $element['group_example']['#states'] = [ - 'visible' => [ - ':input[name="field_are_you_ok"]' => ['value' => 'yes'], - ], - ]; - } + $element['#fieldgroups']['my_group']['region'] = 'new_region'; } /** diff --git a/web/modules/field_group/field_group.info.yml b/web/modules/field_group/field_group.info.yml index d1c746ca45c62b1bfda6f752a519156375650f8d..42618f0d09d7c212d84d5c194f31d42ce77d7220 100644 --- a/web/modules/field_group/field_group.info.yml +++ b/web/modules/field_group/field_group.info.yml @@ -2,12 +2,12 @@ name: 'Field Group' type: module description: 'Provides the ability to group your fields on both form and display.' package : Fields -# core: 8.x +core: 8.x +core_version_requirement: ^8 || ^9 dependencies: - drupal:field -# Information added by Drupal.org packaging script on 2019-05-23 -version: '8.x-3.0-rc1' -core: '8.x' +# Information added by Drupal.org packaging script on 2020-01-28 +version: '8.x-3.0' project: 'field_group' -datestamp: 1558647188 +datestamp: 1580250789 diff --git a/web/modules/field_group/field_group.install b/web/modules/field_group/field_group.install index 7213f09bc4042c190e2bac05cfcc4f7ac3111346..659cf67a2fb029c6fbd4cf7270e1d34bc62a7422 100644 --- a/web/modules/field_group/field_group.install +++ b/web/modules/field_group/field_group.install @@ -6,26 +6,8 @@ */ /** - * Set the `region` portion of each field group. + * Removed in favor of hook_post_update script. */ function field_group_update_8301() { - foreach (['entity_form_display', 'entity_view_display'] as $entity_type) { - foreach (\Drupal::entityTypeManager()->getStorage($entity_type)->loadMultiple() as $display) { - /** @var \Drupal\Core\Entity\Display\EntityDisplayInterface $display */ - if (in_array('field_group', $display->getThirdPartyProviders())) { - $field_groups = $display->getThirdPartySettings('field_group'); - $updated = FALSE; - foreach ($field_groups as $group_name => $data) { - if (!isset($data['region'])) { - $data['region'] = 'content'; - $display->setThirdPartySetting('field_group', $group_name, $data); - $updated = TRUE; - } - } - if ($updated) { - $display->save(); - } - } - } - } + // @see field_group_post_update_0001(). } diff --git a/web/modules/field_group/field_group.module b/web/modules/field_group/field_group.module index b2711b240805d924551a9cb6f1f9178dee4ef6ea..2e794568cfddea2dd4300c361f6528587964c412 100644 --- a/web/modules/field_group/field_group.module +++ b/web/modules/field_group/field_group.module @@ -2,7 +2,7 @@ /** * @file - * Allows administrators to attach custom fields to fieldable types. + * Allows administrators to attach field groups. */ use Drupal\Core\Routing\RouteMatchInterface; @@ -182,9 +182,26 @@ function field_group_form_entity_view_display_edit_form_alter(&$form, FormStateI * Implements hook_field_info_max_weight(). */ function field_group_field_info_max_weight($entity_type, $bundle, $context, $context_mode) { + // Prevent recursion. + // @see https://www.drupal.org/project/drupal/issues/2966137 + static $recursion_tracker = []; + + // Track the entity display. + $key = $entity_type . ':' . $bundle . ':' . $context . ':' . $context_mode; + + // If entity display check was attempted but did not finish, do not continue. + if (isset($recursion_tracker[$key])) { + return NULL; + } + + // Mark this as an attempt at entity display check. + $recursion_tracker[$key] = TRUE; $groups = field_group_info_groups($entity_type, $bundle, $context, $context_mode); + // Remove the indicator once the entity display is successfully checked. + unset($recursion_tracker[$key]); + $weights = []; foreach ($groups as $group) { $weights[] = $group->weight; @@ -201,7 +218,7 @@ function field_group_form_alter(array &$form, FormStateInterface $form_state) { if ($form_object instanceof ContentEntityFormInterface && !$form_object instanceof ConfirmFormInterface) { /** - * @var \Drupal\Core\Entity\Entity\EntityFormDisplayInterface $form_display + * @var \Drupal\Core\Entity\Display\EntityFormDisplayInterface $form_display */ $storage = $form_state->getStorage(); if (!empty($storage['form_display'])) { @@ -239,7 +256,36 @@ function field_group_inline_entity_form_entity_form_alter(&$entity_form, FormSta ]; field_group_attach_groups($entity_form, $context); - $entity_form['#process'][] = 'field_group_form_process'; + field_group_form_process($entity_form); +} + +/** + * Implements hook_form_layout_builder_update_block_alter(). + */ +function field_group_form_layout_builder_update_block_alter(&$form, FormStateInterface $form_state) { + // Attach fieldgroups to the layout builder form for custom block types. + if (!isset($form['settings']['block_form']['#block'])) { + return; + } + + $context = [ + 'entity_type' => $form['settings']['block_form']['#block']->getEntityTypeId(), + 'bundle' => $form['settings']['block_form']['#block']->bundle(), + 'entity' => $form['settings']['block_form']['#block'], + 'display_context' => 'form', + 'mode' => 'default', + ]; + + field_group_attach_groups($form['settings']['block_form'], $context); + $form['settings']['block_form']['#process'][] = 'field_group_form_process'; +} + +/** + * Implements hook_form_layout_builder_add_block_alter(). + */ +function field_group_form_layout_builder_add_block_alter(&$form, FormStateInterface $form_state) { + // Call the update hook. + field_group_form_layout_builder_update_block_alter($form, $form_state); } /** @@ -283,6 +329,8 @@ function field_group_entity_view_alter(&$build, EntityInterface $entity, EntityD * Form that is being rendered. * * @deprecated Use field_group_form_process instead. + * + * @return array */ function field_group_form_pre_render(array $element) { return field_group_form_process($element); @@ -325,6 +373,9 @@ function field_group_form_process(array &$element, FormStateInterface $form_stat $element[$group_name]['#parents'] = $parents; $group_children_parent_group = implode('][', $parents); foreach ($group->children as $child) { + if (!empty($element[$child]['#field_group_ignore'])) { + continue; + } $element[$child]['#group'] = $group_children_parent_group; } } @@ -358,6 +409,8 @@ function field_group_form_process(array &$element, FormStateInterface $form_stat * * @param array $element * Entity being rendered. + * + * @return array */ function field_group_entity_view_pre_render(array $element) { field_group_build_entity_groups($element, 'view'); @@ -446,10 +499,9 @@ function field_group_field_group_form_process_build_alter(array &$element, $form /** * Implements hook_field_group_build_pre_render_alter(). * - * @param array $elements - * By address.field_group_entity_display_build_alter + * @param array $element */ -function field_group_field_group_build_pre_render_alter(& $element) { +function field_group_field_group_build_pre_render_alter(&$element) { // Someone is doing a node view, in a node view. Reset content. if (isset($element['#node']->content) && count($element['#node']->content) > 0) { $element['#node']->content = []; @@ -780,6 +832,8 @@ function field_group_pre_render(& $element, $group, & $rendering_object) { * * @param $context * The display context (entity type, form or view). + * + * @return string */ function field_group_get_content_element_key($context = 'default') { $keys = &drupal_static('field_group_content_elements'); @@ -794,16 +848,13 @@ function field_group_get_content_element_key($context = 'default') { if (isset($keys[$context])) { $key = $keys[$context]; } + return $key; } /** * Saves a group definition. * - * This function is called by ctools export when calls are made through - * ctools_export_crud_save(). It's also used as an api method to add groups to a - * display. - * * @param \stdClass $group * A group definition. * @param \Drupal\Core\Entity\Display\EntityDisplayInterface $display @@ -811,6 +862,8 @@ function field_group_get_content_element_key($context = 'default') { * * @return \Drupal\Core\Entity\Display\EntityDisplayInterface|null * The updated entity display. + * + * @throws \Drupal\Core\Entity\EntityStorageException */ function field_group_group_save($group, $display = NULL) { if ($display === NULL) { @@ -859,8 +912,10 @@ function field_group_group_save($group, $display = NULL) { * * @param $group * A group definition. + * + * @throws \Drupal\Core\Entity\EntityStorageException */ -function field_group_group_delete($group) { +function field_group_delete_field_group($group) { if ($group->context == 'form') { $display = EntityFormDisplay::load($group->entity_type . '.' . $group->bundle . '.' . $group->mode); } @@ -890,6 +945,8 @@ function field_group_group_delete($group) { * The context of the view mode (form or view) * @param $mode * The view mode. + * + * @return array */ function field_group_info_groups($entity_type, $bundle, $context, $mode) { if ($context == 'form') { @@ -935,6 +992,8 @@ function field_group_info_groups($entity_type, $bundle, $context, $mode) { * The context of the view mode (form or view) * @param $mode * The view mode to load. + * + * @return mixed */ function field_group_load_field_group($group_name, $entity_type, $bundle, $context, $mode) { $groups = field_group_info_groups($entity_type, $bundle, $context, $mode); @@ -956,6 +1015,8 @@ function field_group_load_field_group($group_name, $entity_type, $bundle, $conte * The context of the view mode (form or view) * @param string $mode * The view mode context the group will be rendered. + * + * @return bool */ function field_group_exists($group_name, $entity_type, $bundle, $context, $mode) { return (bool) field_group_load_field_group($group_name, $entity_type, $bundle, $context, $mode); @@ -1005,6 +1066,8 @@ function field_group_remove_empty_form_groups(&$element, $groups, $entity_type) * The element to check the empty state. * @param array $groups * Array of group objects. + * + * @return bool */ function field_group_remove_empty_display_groups(& $element, $groups) { @@ -1039,5 +1102,4 @@ function field_group_remove_empty_display_groups(& $element, $groups) { } return $empty_group; - } diff --git a/web/modules/field_group/field_group.post_update.php b/web/modules/field_group/field_group.post_update.php new file mode 100644 index 0000000000000000000000000000000000000000..04fc1cbccb9570735509f32eead75145d18f692b --- /dev/null +++ b/web/modules/field_group/field_group.post_update.php @@ -0,0 +1,54 @@ +<?php + +/** + * @file + * Post update functions for Field Group. + */ + +/** + * Assign a region to Field Groups. + */ +function field_group_post_update_0001() { + foreach (['entity_form_display', 'entity_view_display'] as $entity_type) { + foreach (\Drupal::entityTypeManager()->getStorage($entity_type)->loadMultiple() as $display) { + /** @var \Drupal\Core\Entity\Display\EntityDisplayInterface $display */ + if (in_array('field_group', $display->getThirdPartyProviders())) { + $updated = FALSE; + + // Take Display Suite regions into account. + $has_ds = FALSE; + $ds_regions = []; + if ($entity_type == 'entity_view_display' && in_array('ds', $display->getThirdPartyProviders())) { + $ds = $display->getThirdPartySettings('ds'); + if (!empty($ds['regions'])) { + foreach ($ds['regions'] as $region_name => $region_fields) { + foreach ($region_fields as $field_name) { + $has_ds = TRUE; + $ds_regions[$field_name] = $region_name; + } + } + } + } + + $field_groups = $display->getThirdPartySettings('field_group'); + foreach ($field_groups as $group_name => $data) { + if (!isset($data['region'])) { + $region = 'content'; + if ($has_ds) { + $region = 'hidden'; + if (isset($ds_regions[$group_name])) { + $region = $ds_regions[$group_name]; + } + } + $data['region'] = $region; + $display->setThirdPartySetting('field_group', $group_name, $data); + $updated = TRUE; + } + } + if ($updated) { + $display->save(); + } + } + } + } +} diff --git a/web/modules/field_group/field_group.services.yml b/web/modules/field_group/field_group.services.yml index 1eafd00a992df9cbb300e0bd4afcb9001a8fa46d..5c6f68583c585d285ccc6818d7831fb49a392b26 100644 --- a/web/modules/field_group/field_group.services.yml +++ b/web/modules/field_group/field_group.services.yml @@ -4,7 +4,7 @@ services: parent: default_plugin_manager field_group.subscriber: class: Drupal\field_group\Routing\RouteSubscriber - arguments: ['@entity.manager'] + arguments: ['@entity_type.manager'] tags: - { name: event_subscriber } field_group.param_converter: diff --git a/web/modules/field_group/formatters/tabs/horizontal-tabs.css b/web/modules/field_group/formatters/tabs/horizontal-tabs.css index 5cb6ce314fb055fc3a1dea9604ad61144e0ab476..b28d5c9dea7c430a2eb625815e2ec95ddbfdf4c7 100644 --- a/web/modules/field_group/formatters/tabs/horizontal-tabs.css +++ b/web/modules/field_group/formatters/tabs/horizontal-tabs.css @@ -13,10 +13,10 @@ display: inline-block; margin: 0; border: 0; - padding: 0px; + padding: 0; list-style: none; - background-color: #dedede; - border-right: 1px solid #dedede; /* LTR */ + background-color: #eee; + border-bottom: 1px solid #ccc; /* LTR */ width: 100%; height: auto; clear: both; @@ -41,7 +41,6 @@ .horizontal-tabs .horizontal-tab-button { background: #eee; border-right: 1px solid #ccc; /* LTR */ - padding: 1px; padding-top: 0; margin: 0; min-width: 5em; /* IE7 */ @@ -62,7 +61,7 @@ .horizontal-tabs .horizontal-tab-button a:hover { outline: none; - background-color: #ededdd; + background-color: #fff; } .horizontal-tabs .horizontal-tab-button li:hover, @@ -83,7 +82,8 @@ .horizontal-tab-button.selected { background-color: #fff; - padding: 0 0 1px 0; + border-bottom: 1px solid #fff; + margin-bottom: -1px; } [dir="rtl"] .horizontal-tab-button.selected { @@ -95,9 +95,9 @@ .horizontal-tabs ul.horizontal-tabs-list li.selected a { display: block; text-decoration: none; - padding: 0.5em 0.6em 0.3em 0.6em; + padding: 0.6em 1em; position: relative; - top: 0px; + top: 0; } .horizontal-tab-button .selected strong { @@ -121,10 +121,3 @@ div.field-group-htabs-wrapper .field-group-format-wrapper { padding: 0 0 0.6em; } -/*hide*/ -.horizontal-tabs .horizontal-tab-hidden { - display: block; - position: absolute; - top: -100000000px; - width: 100%; -} diff --git a/web/modules/field_group/formatters/tabs/horizontal-tabs.js b/web/modules/field_group/formatters/tabs/horizontal-tabs.js index 363e63e4e1db92d31238c4b65b1f81e450d99a82..ca0dc04ca51d0cf062ddf1c2b156cd8c4cc8eb4b 100644 --- a/web/modules/field_group/formatters/tabs/horizontal-tabs.js +++ b/web/modules/field_group/formatters/tabs/horizontal-tabs.js @@ -149,9 +149,11 @@ .each(function () { var tab = $(this).data('horizontalTab'); tab.details.addClass('horizontal-tab-hidden'); + tab.details.hide(); tab.item.removeClass('selected'); }) .end() + .show() .siblings(':hidden.horizontal-tabs-active-tab') .val(this.details.attr('id')); this.item.addClass('selected'); @@ -175,6 +177,9 @@ tabShow: function () { // Display the tab. this.item.removeClass('horizontal-tab-hidden'); + this.item.show(); + alert('show'); + // Update .first marker for items. We need recurse from parent to retain the // actual DOM element order as jQuery implements sortOrder, but not as public // method. @@ -195,6 +200,9 @@ tabHide: function () { // Hide this tab. this.item.addClass('horizontal-tab-hidden'); + this.item.hide(); + alert('hide'); + // Update .first marker for items. We need recurse from parent to retain the // actual DOM element order as jQuery implements sortOrder, but not as public // method. diff --git a/web/modules/field_group/formatters/tabs/tabs.js b/web/modules/field_group/formatters/tabs/tabs.js index c2c5b5d31a54aeb937c945f44c6fd18de0b3ca07..9e1bdb4003f740ea26f1a98434599e12c6ac2302 100644 --- a/web/modules/field_group/formatters/tabs/tabs.js +++ b/web/modules/field_group/formatters/tabs/tabs.js @@ -15,21 +15,28 @@ // Add required fields mark to any element containing required fields var direction = group_info.settings.direction; - $(context).find('[data-' + direction + '-tabs-panes] details').once('fieldgroup-effects').each(function () { - - var $this = $(this); - if (typeof $(this).data(direction + 'Tab') !== 'undefined') { - - if ($this.is('.required-fields') && ($this.find('[required]').length > 0 || $this.find('.form-required').length > 0)) { - $this.data(direction + 'Tab').link.find('strong:first').addClass('form-required'); - } - - if ($('.error', $this).length) { - $this.data(direction + 'Tab').link.parent().addClass('error'); - Drupal.FieldGroup.setGroupWithfocus($this); - $this.data(direction + 'Tab').focus(); + $(context).find('[data-' + direction + '-tabs-panes]').each(function () { + var errorFocussed = false; + $(this).find('> details').once('fieldgroup-effects').each(function () { + var $this = $(this); + if (typeof $this.data(direction + 'Tab') !== 'undefined') { + + if ($this.is('.required-fields') && ($this.find('[required]').length > 0 || $this.find('.form-required').length > 0)) { + $this.data(direction + 'Tab').link.find('strong:first').addClass('form-required'); + } + + if ($('.error', $this).length) { + $this.data(direction + 'Tab').link.parent().addClass('error'); + + // Focus the first tab with error. + if (!errorFocussed) { + Drupal.FieldGroup.setGroupWithfocus($this); + $this.data(direction + 'Tab').focus(); + errorFocussed = true; + } + } } - } + }); }); } diff --git a/web/modules/field_group/includes/field_ui.inc b/web/modules/field_group/includes/field_ui.inc index 318dd1ef9087437f17559e55935e956f102fc726..0a14e6b7719b3d3f693c0d512ff6fc16cd4015c4 100644 --- a/web/modules/field_group/includes/field_ui.inc +++ b/web/modules/field_group/includes/field_ui.inc @@ -42,7 +42,8 @@ function field_group_field_ui_form_params($form, EntityDisplayBase $display) { $params->parents = []; foreach ($params->groups as $name => $group) { foreach ($group->children as $child) { - // Field UI js sometimes can trigger an endless loop. Check if the parent of this field is not a child. + // Field UI js sometimes can trigger an endless loop. Check if the parent + // of this field is not a child. if ($child !== $group->parent_name) { $params->parents[$child] = $name; } @@ -50,12 +51,23 @@ function field_group_field_ui_form_params($form, EntityDisplayBase $display) { } // Get possible regions. - $layout_info = $display->getThirdPartySettings('field_layout'); - if (!empty($layout_info) && isset($layout_info['id'])) { - $layout = \Drupal::service('plugin.manager.core.layout')->getDefinition($layout_info['id']); + // TODO remove the field layout part when it's remove from in core. + // see https://www.drupal.org/project/field_group/issues/3086019 + $ds_info = $display->getThirdPartySettings('ds'); + $field_layout_info = $display->getThirdPartySettings('field_layout'); + /** @var \Drupal\Core\Layout\LayoutDefinition $layout */ + if (!empty($field_layout_info) && isset($field_layout_info['id'])) { + $layout = \Drupal::service('plugin.manager.core.layout')->getDefinition($field_layout_info['id']); $params->available_regions = $layout->getRegionNames(); $params->default_region = $layout->getDefaultRegion() ?: 'hidden'; } + elseif (!empty($ds_info['layout']['id'])) { + $layout = \Drupal::service('plugin.manager.core.layout')->getDefinition($ds_info['layout']['id']); + $params->available_regions = $layout->getRegionNames(); + // Hidden is an available region too, as weird as it may seems. + $params->available_regions[] = 'hidden'; + $params->default_region = $layout->getDefaultRegion() ?: 'hidden'; + } else { $params->available_regions = ['content', 'hidden']; $params->default_region = 'hidden'; @@ -93,7 +105,7 @@ function field_group_field_ui_display_form_alter(&$form, FormStateInterface $for $entity_display_form = $form_state->getBuildInfo()['callback_object']; if (!$entity_display_form instanceof EntityDisplayFormBase) { - throw new InvalidArgumentException('Unkown callback object.'); + throw new InvalidArgumentException('Unknown callback object.'); } $display = $entity_display_form->getEntity(); @@ -166,7 +178,7 @@ function field_group_field_ui_display_form_alter(&$form, FormStateInterface $for '#region_callback' => 'field_group_display_overview_row_region', '#js_settings' => ['rowHandler' => 'group'], 'human_name' => [ - '#markup' => Html::escape(t($group->label)), + '#markup' => $group->label, '#prefix' => '<span class="group-label">', '#suffix' => '</span>', ], @@ -453,8 +465,8 @@ function field_group_field_overview_submit($form, FormStateInterface $form_state $group = $groups[$group_name]; $group->label = $field_group_form_state[$group_name]->label; - // Sometimes field UI does a fuckup if people drag to fast when switching nested values. - // This results in an endless loop => Cleanup before saving. + // Sometimes field UI freaks a bit if people drag to fast when switching + // nested values which results in an endless loop, so cleanup first. // unset($children[$group_name][$form_values[$group_name]['parent']]);. $group->children = array_keys($children[$group_name]); $group->parent_name = $form_values[$group_name]['parent']; diff --git a/web/modules/field_group/src/Element/HorizontalTabs.php b/web/modules/field_group/src/Element/HorizontalTabs.php index dab221c9226d911371268f7bf45db4d5cf5fa2a8..e3c642d8d14200f0b9cbb7e64e8a829395732810 100644 --- a/web/modules/field_group/src/Element/HorizontalTabs.php +++ b/web/modules/field_group/src/Element/HorizontalTabs.php @@ -72,6 +72,18 @@ public static function preRenderGroup($element) { } } + // Search for the correct default active tab. + $group_identifier = implode('][', $element['#parents']); + if (!empty($element['#groups'][$group_identifier])) { + $children = Element::children($element['#groups'][$group_identifier], TRUE); + foreach ($children as $key) { + if (!empty($element['#groups'][$group_identifier][$key]['#open'])) { + $element['#default_tab'] = $element['#groups'][$group_identifier][$key]['#id']; + $element[str_replace('][', '__', $group_identifier) . '__active_tab']['#value'] = $element['#default_tab']; + } + } + } + return $element; } @@ -118,18 +130,7 @@ public static function processHorizontalTabs(array &$element, FormStateInterface $element['#default_tab'] = $form_state->getValue($name . '__active_tab'); } - $groups = &$form_state->getGroups(); - $group_name = $element['#group_name']; $displayed_tab = isset($element['#default_tab']) ? $element['#default_tab'] : ''; - if (isset($groups[$group_name]) && empty($displayed_tab)) { - foreach (Element::children($groups[$group_name]) as $child) { - $child_group = $groups[$group_name][$child]; - if (!empty($child_group['#open']) || empty($displayed_tab)) { - // Use the last open group or the first group if none are open. - $displayed_tab = $child_group['#id']; - } - } - } // The JavaScript stores the currently selected tab in this hidden // field so that the active tab can be restored the next time the diff --git a/web/modules/field_group/src/Element/VerticalTabs.php b/web/modules/field_group/src/Element/VerticalTabs.php index 5b56bf4694fe47ce88ee11ae9069f94dd93dae03..598e24cf472082fb8f7dca43f7bc8fb412bc6a2f 100644 --- a/web/modules/field_group/src/Element/VerticalTabs.php +++ b/web/modules/field_group/src/Element/VerticalTabs.php @@ -47,6 +47,18 @@ public static function preRenderGroup($element) { } } + // Search for the correct default active tab. + $group_identifier = implode('][', $element['#parents']); + if (!empty($element['#groups'][$group_identifier])) { + $children = Element::children($element['#groups'][$group_identifier], TRUE); + foreach ($children as $key) { + if (!empty($element['#groups'][$group_identifier][$key]['#open'])) { + $element['#default_tab'] = $element['#groups'][$group_identifier][$key]['#id']; + $element[str_replace('][', '__', $group_identifier) . '__active_tab']['#value'] = $element['#default_tab']; + } + } + } + return $element; } diff --git a/web/modules/field_group/src/Form/FieldGroupAddForm.php b/web/modules/field_group/src/Form/FieldGroupAddForm.php index 987a3757b2c33b715e9c545d88736b217e904efe..a69b5904bec24edc63288fa5b1063daa569f007e 100644 --- a/web/modules/field_group/src/Form/FieldGroupAddForm.php +++ b/web/modules/field_group/src/Form/FieldGroupAddForm.php @@ -112,10 +112,10 @@ public function buildForm(array $form, FormStateInterface $form_state, $entity_t $this->context = $context; if ($context == 'form') { - $this->mode = \Drupal::request()->get('form_mode_name'); + $this->mode = $this->getRequest()->get('form_mode_name'); } else { - $this->mode = \Drupal::request()->get('view_mode_name'); + $this->mode = $this->getRequest()->get('view_mode_name'); } if (empty($this->mode)) { @@ -153,7 +153,7 @@ public function buildFormatterSelectionForm(array &$form, FormStateInterface $fo '#type' => 'select', '#title' => $this->t('Add a new group'), '#options' => $formatter_options, - '#empty_option' => $this->t('- Select a group type -'), + '#empty_option' => $this->t('- Select a field group type -'), '#required' => TRUE, ]; @@ -272,6 +272,7 @@ public function submitForm(array &$form, FormStateInterface $form_state) { 'parent_name' => '', 'weight' => 20, 'format_type' => $form_state->get('group_formatter'), + 'region' => 'hidden', ]; $new_group->format_settings = $form_state->getValue('format_settings'); diff --git a/web/modules/field_group/src/Form/FieldGroupDeleteForm.php b/web/modules/field_group/src/Form/FieldGroupDeleteForm.php index 3cf86b88f90b9aff18a184fe0e4e2f54f838a058..fafb76f1f1eb76757fd7c875d1072849dd7c4836 100644 --- a/web/modules/field_group/src/Form/FieldGroupDeleteForm.php +++ b/web/modules/field_group/src/Form/FieldGroupDeleteForm.php @@ -80,7 +80,7 @@ public function submitForm(array &$form, FormStateInterface $form_state) { $bundles = \Drupal::service('entity_type.bundle.info')->getAllBundleInfo(); $bundle_label = $bundles[$this->fieldGroup->entity_type][$this->fieldGroup->bundle]['label']; - field_group_group_delete($this->fieldGroup); + field_group_delete_field_group($this->fieldGroup); $this->messenger->addMessage(t('The group %group has been deleted from the %type content type.', ['%group' => t($this->fieldGroup->label), '%type' => $bundle_label])); diff --git a/web/modules/field_group/src/Plugin/Derivative/FieldGroupLocalAction.php b/web/modules/field_group/src/Plugin/Derivative/FieldGroupLocalAction.php index 64972b603c04eb0c0beb0ff72354a7cc26f95de0..5990efd927dded4861a11e89388bf90c4eccc86a 100644 --- a/web/modules/field_group/src/Plugin/Derivative/FieldGroupLocalAction.php +++ b/web/modules/field_group/src/Plugin/Derivative/FieldGroupLocalAction.php @@ -63,7 +63,7 @@ public function getDerivativeDefinitions($base_plugin_definition) { if ($entity_type->get('field_ui_base_route')) { $default_options = [ - 'title' => $this->t('Add group'), + 'title' => $this->t('Add field group'), ]; $this->derivatives['field_group_add_' . $entity_type_id . '_form_display'] = [ diff --git a/web/modules/field_group/src/Plugin/field_group/FieldGroupFormatter/AccordionItem.php b/web/modules/field_group/src/Plugin/field_group/FieldGroupFormatter/AccordionItem.php index afab3bc4a119c698a8c55acfc802d24e2e79b5ae..dd8feac3715ff3bc8bd2e36a4f0d0c25b5baa440 100644 --- a/web/modules/field_group/src/Plugin/field_group/FieldGroupFormatter/AccordionItem.php +++ b/web/modules/field_group/src/Plugin/field_group/FieldGroupFormatter/AccordionItem.php @@ -35,7 +35,7 @@ public function process(&$element, $processed_object) { $element += [ '#type' => 'field_group_accordion_item', '#effect' => $this->getSetting('effect'), - '#title' => Html::escape($this->t($this->getLabel())), + '#title' => $this->getLabel(), ]; if ($this->getSetting('id')) { diff --git a/web/modules/field_group/src/Plugin/field_group/FieldGroupFormatter/Details.php b/web/modules/field_group/src/Plugin/field_group/FieldGroupFormatter/Details.php index d1384cc1c65832a842fac5f52868117afe5ee053..fdbde635baa72501dfd15da3b93f8195d92ee599 100644 --- a/web/modules/field_group/src/Plugin/field_group/FieldGroupFormatter/Details.php +++ b/web/modules/field_group/src/Plugin/field_group/FieldGroupFormatter/Details.php @@ -27,7 +27,7 @@ public function process(&$element, $processed_object) { $element += [ '#type' => 'details', - '#title' => Html::escape($this->t($this->getLabel())), + '#title' => $this->getLabel(), '#open' => $this->getSetting('open'), '#description' => $this->getSetting('description'), ]; diff --git a/web/modules/field_group/src/Plugin/field_group/FieldGroupFormatter/DetailsSidebar.php b/web/modules/field_group/src/Plugin/field_group/FieldGroupFormatter/DetailsSidebar.php new file mode 100644 index 0000000000000000000000000000000000000000..aa1563bc1c34d427c5110bdc0ae894d9547cce89 --- /dev/null +++ b/web/modules/field_group/src/Plugin/field_group/FieldGroupFormatter/DetailsSidebar.php @@ -0,0 +1,73 @@ +<?php + +namespace Drupal\field_group\Plugin\field_group\FieldGroupFormatter; + +/** + * Details Sidebar element. + * + * @FieldGroupFormatter( + * id = "details_sidebar", + * label = @Translation("Details Sidebar"), + * description = @Translation("Add a details sidebar element"), + * supported_contexts = { + * "form", + * "view" + * } + * ) + */ +class DetailsSidebar extends Details { + + /** + * {@inheritdoc} + */ + public function process(&$element, $processed_object) { + parent::process($element, $processed_object); + + $element['#group'] = 'advanced'; + + if ($this->getSetting('weight')) { + $element['#weight'] = $this->getSetting('weight'); + } + } + + /** + * {@inheritdoc} + */ + public function settingsForm() { + $form = parent::settingsForm(); + + $form['weight'] = [ + '#type' => 'number', + '#title' => $this->t('Weight'), + '#default_value' => $this->getSetting('weight'), + ]; + + return $form; + } + + /** + * {@inheritdoc} + */ + public function settingsSummary() { + $summary = parent::settingsSummary(); + + if ($this->getSetting('weight')) { + $summary[] = $this->t('Weight: @weight', + ['@weight' => $this->getSetting('weight')] + ); + } + + return $summary; + } + + /** + * {@inheritdoc} + */ + public static function defaultContextSettings($context) { + $defaults = parent::defaultContextSettings($context); + $defaults['weight'] = 0; + + return $defaults; + } + +} diff --git a/web/modules/field_group/src/Plugin/field_group/FieldGroupFormatter/Fieldset.php b/web/modules/field_group/src/Plugin/field_group/FieldGroupFormatter/Fieldset.php index 4245b7ee35a19fb0a1a8e448b596ee2a76004b63..327d857b3375c9495de38a816a8f0f59783be074 100644 --- a/web/modules/field_group/src/Plugin/field_group/FieldGroupFormatter/Fieldset.php +++ b/web/modules/field_group/src/Plugin/field_group/FieldGroupFormatter/Fieldset.php @@ -27,7 +27,7 @@ public function process(&$element, $processed_object) { $element += [ '#type' => 'fieldset', - '#title' => Html::escape($this->t($this->getLabel())), + '#title' => $this->getLabel(), '#attributes' => [], '#description' => $this->getSetting('description'), ]; diff --git a/web/modules/field_group/src/Plugin/field_group/FieldGroupFormatter/HtmlElement.php b/web/modules/field_group/src/Plugin/field_group/FieldGroupFormatter/HtmlElement.php index 60e4d539c1655bb6e2296cf4fd8da70eda0429fb..94015806df54c84c7dacb95ac321124b5390fc8d 100644 --- a/web/modules/field_group/src/Plugin/field_group/FieldGroupFormatter/HtmlElement.php +++ b/web/modules/field_group/src/Plugin/field_group/FieldGroupFormatter/HtmlElement.php @@ -71,7 +71,7 @@ public function process(&$element, $processed_object) { $element['#attributes'] = $element_attributes; if ($this->getSetting('show_label')) { $element['#title_element'] = $this->getSetting('label_element'); - $element['#title'] = Html::escape($this->t($this->getLabel())); + $element['#title'] = $this->getLabel(); $element['#title_attributes'] = new Attribute(); if (!empty($this->getSetting('label_element_classes'))) { diff --git a/web/modules/field_group/src/Plugin/field_group/FieldGroupFormatter/Tab.php b/web/modules/field_group/src/Plugin/field_group/FieldGroupFormatter/Tab.php index fe58da6dfb16c6f1732d0d1e324b4d4187a5b7e4..ba2c728baa24f7a4984207ed1b1279cb18cd13ef 100644 --- a/web/modules/field_group/src/Plugin/field_group/FieldGroupFormatter/Tab.php +++ b/web/modules/field_group/src/Plugin/field_group/FieldGroupFormatter/Tab.php @@ -34,7 +34,7 @@ public function process(&$element, $processed_object) { $add = [ '#type' => 'details', - '#title' => Html::escape($this->t($this->getLabel())), + '#title' => $this->getLabel(), '#description' => $this->getSetting('description'), '#group' => $this->group->parent_name, ]; diff --git a/web/modules/field_group/src/Plugin/field_group/FieldGroupFormatter/Tabs.php b/web/modules/field_group/src/Plugin/field_group/FieldGroupFormatter/Tabs.php index 56d58d45dbe2c49c1a5a73a835f5697055c8fdbc..de6b562b73662d86f61a78265fc860ade9fb80b9 100644 --- a/web/modules/field_group/src/Plugin/field_group/FieldGroupFormatter/Tabs.php +++ b/web/modules/field_group/src/Plugin/field_group/FieldGroupFormatter/Tabs.php @@ -46,7 +46,7 @@ public function process(&$element, $processed_object) { // By default tabs don't have titles but you can override it in the theme. if ($this->getLabel()) { - $element['#title'] = Html::escape($this->getLabel()); + $element['#title'] = $this->getLabel(); } $element += [ @@ -54,14 +54,6 @@ public function process(&$element, $processed_object) { '#theme_wrappers' => [$this->getSetting('direction') . '_tabs'], ]; - // Search for a tab that was marked as open. First one wins. - foreach (Element::children($element) as $tab_name) { - if (!empty($element[$tab_name]['#open'])) { - $element[$this->group->group_name . '__active_tab']['#default_value'] = $tab_name; - break; - } - } - } /** diff --git a/web/modules/field_group/src/Routing/RouteSubscriber.php b/web/modules/field_group/src/Routing/RouteSubscriber.php index 2ca276b2d24683a34a630f92137b858f881ac040..bae6a2c3a08d4f54b447a355077a92c20e71696a 100644 --- a/web/modules/field_group/src/Routing/RouteSubscriber.php +++ b/web/modules/field_group/src/Routing/RouteSubscriber.php @@ -68,7 +68,7 @@ protected function alterRoutes(RouteCollection $collection) { $defaults_add = [ 'entity_type_id' => $entity_type_id, '_form' => '\Drupal\field_group\Form\FieldGroupAddForm', - '_title' => 'Add group', + '_title' => 'Add field group', ]; // If the entity type has no bundles and it doesn't use {bundle} in its diff --git a/web/modules/field_group/tests/modules/field_group_test/field_group_test.info.yml b/web/modules/field_group/tests/modules/field_group_test/field_group_test.info.yml index cb1a2dd8c1f6671fcf34e799356242b31cbcba6b..279040ed8eb78698f92f3f484c8bbe884cc6705f 100644 --- a/web/modules/field_group/tests/modules/field_group_test/field_group_test.info.yml +++ b/web/modules/field_group/tests/modules/field_group_test/field_group_test.info.yml @@ -1,12 +1,11 @@ name: 'Field Group Test' description: 'Test module for Field Group' -# core: 8.x +core: 8.x package: 'Fields' type: module hidden: TRUE -# Information added by Drupal.org packaging script on 2019-05-23 -version: '8.x-3.0-rc1' -core: '8.x' +# Information added by Drupal.org packaging script on 2020-01-28 +version: '8.x-3.0' project: 'field_group' -datestamp: 1558647188 +datestamp: 1580250789 diff --git a/web/modules/field_group/tests/src/Functional/EntityDisplayTest.php b/web/modules/field_group/tests/src/Functional/EntityDisplayTest.php index ce2e20d70389d477a6a3840da9c6074e83577772..7eda8fa638a89e03d466e6ecf767db2378141c5e 100644 --- a/web/modules/field_group/tests/src/Functional/EntityDisplayTest.php +++ b/web/modules/field_group/tests/src/Functional/EntityDisplayTest.php @@ -40,6 +40,11 @@ class EntityDisplayTest extends BrowserTestBase { */ protected $node; + /** + * {@inheritdoc} + */ + protected $defaultTheme = 'classy'; + /** * {@inheritdoc} */ diff --git a/web/modules/field_group/tests/src/Functional/FieldGroupWithoutFieldUiTest.php b/web/modules/field_group/tests/src/Functional/FieldGroupWithoutFieldUiTest.php index bcb76009846248a894cbc7bfb4273e2d39f14e75..4c443882be7d184c5ddd28ee718f9bcd4477956d 100644 --- a/web/modules/field_group/tests/src/Functional/FieldGroupWithoutFieldUiTest.php +++ b/web/modules/field_group/tests/src/Functional/FieldGroupWithoutFieldUiTest.php @@ -17,6 +17,11 @@ class FieldGroupWithoutFieldUiTest extends BrowserTestBase { */ public static $modules = ['field_group', 'block']; + /** + * {@inheritdoc} + */ + protected $defaultTheme = 'stark'; + /** * Test that local actions show up without field ui enabled. */ diff --git a/web/modules/field_group/tests/src/Functional/ManageDisplayTest.php b/web/modules/field_group/tests/src/Functional/ManageDisplayTest.php index f05c56d1c23ef58265e1d68899fd9a2d19452450..f23f7f62c4e4af8c2c3eaf573bc9282c639549bd 100644 --- a/web/modules/field_group/tests/src/Functional/ManageDisplayTest.php +++ b/web/modules/field_group/tests/src/Functional/ManageDisplayTest.php @@ -25,7 +25,10 @@ class ManageDisplayTest extends BrowserTestBase { */ protected $type; - protected $strictConfigSchema = FALSE; + /** + * {@inheritdoc} + */ + protected $defaultTheme = 'stark'; /** * {@inheritdoc} @@ -84,6 +87,9 @@ public function testCreateGroup() { $this->group = field_group_load_field_group($group_name, 'node', $this->type, 'form', 'default'); $this->assertNotNull($group, 'Group was loaded'); + // Test if region key is set. + $this->assertEquals('hidden', $this->group->region); + // Add new group on the 'Manage display' page. $this->drupalPostForm('admin/structure/types/manage/' . $this->type . '/display/add-group', $group, 'Save and continue'); $this->drupalPostForm(NULL, [], 'Create group'); diff --git a/web/modules/field_group/tests/src/FunctionalJavascript/FieldGroupUiTest.php b/web/modules/field_group/tests/src/FunctionalJavascript/FieldGroupUiTest.php index e237c73f143a0ea581c84400e5f1b1c416fd0c4f..48b9eb4efb0ebafd2a65e13d1b5bc824a54de89b 100644 --- a/web/modules/field_group/tests/src/FunctionalJavascript/FieldGroupUiTest.php +++ b/web/modules/field_group/tests/src/FunctionalJavascript/FieldGroupUiTest.php @@ -30,6 +30,11 @@ class FieldGroupUiTest extends WebDriverTestBase { */ protected $nodeType; + /** + * {@inheritdoc} + */ + protected $defaultTheme = 'stark'; + /** * {@inheritdoc} */ @@ -62,15 +67,19 @@ public function setUp() { */ public function testCreateAndEdit() { foreach (['test_1', 'test_2'] as $name) { - $group = [ - 'group_formatter' => 'details', - 'label' => 'Test 1', - 'group_name' => $name, - ]; - - // Add new group on the 'Manage form display' page. - $this->drupalPostForm('admin/structure/types/manage/' . $this->nodeType . '/form-display/add-group', $group, 'Save and continue'); - $this->drupalPostForm(NULL, [], 'Create group'); + $this->drupalGet('admin/structure/types/manage/' . $this->nodeType . '/form-display/add-group'); + $page = $this->getSession()->getPage(); + + // Type the label to activate the machine name field and the edit button. + $page->fillField('group_formatter', 'details'); + $page->fillField('label', 'Test 1'); + // Wait for the machine name widget to be activated. + $this->assertSession()->waitForElementVisible('css', 'button[type=button].link:contains(Edit)'); + // Activate the machine name text field. + $page->pressButton('Edit'); + $page->fillField('Machine-readable name', $name); + $page->pressButton('Save and continue'); + $page->pressButton('Create group'); } // Update title in group 1. @@ -100,10 +109,7 @@ public function testCreateAndEdit() { /** @var \Drupal\Core\Entity\Display\EntityFormDisplayInterface $display */ $display = EntityFormDisplay::load("node.{$this->nodeType}.default"); $this->assertSame('Test 1 - Update', $display->getThirdPartySetting('field_group', 'group_test_1')['label']); - $this->assertSame('Test 1 - Update', $display->getThirdPartySetting('field_group', 'group_test_1')['format_settings']['label']); - $this->assertSame('Test 2 - Update', $display->getThirdPartySetting('field_group', 'group_test_2')['label']); - $this->assertSame('Test 2 - Update', $display->getThirdPartySetting('field_group', 'group_test_2')['format_settings']['label']); } }