Skip to content
Snippets Groups Projects
Verified Commit 381c38a9 authored by Lauri Timmanee's avatar Lauri Timmanee
Browse files

Issue #3359240 by Utkarsh_33, narendraR, deviantintegral, lauriii,...

Issue #3359240 by Utkarsh_33, narendraR, deviantintegral, lauriii, tim.plunkett, smustgrave, joachim, ckrina, hooroomoo: Enable bundle selection when a new view mode is created
parent e0cbbca6
No related branches found
No related tags found
No related merge requests found
...@@ -86,7 +86,7 @@ ...@@ -86,7 +86,7 @@
prepareDialogButtons($dialog) { prepareDialogButtons($dialog) {
const buttons = []; const buttons = [];
const $buttons = $dialog.find( const $buttons = $dialog.find(
'.form-actions input[type=submit], .form-actions a.button', '.form-actions input[type=submit], .form-actions a.button, .form-actions a.action-link',
); );
$buttons.each(function () { $buttons.each(function () {
const $originalButton = $(this).css({ display: 'none' }); const $originalButton = $(this).css({ display: 'none' });
......
...@@ -2,6 +2,7 @@ field_ui.entity_view_mode_add: ...@@ -2,6 +2,7 @@ field_ui.entity_view_mode_add:
route_name: field_ui.entity_view_mode_add route_name: field_ui.entity_view_mode_add
title: 'Add view mode' title: 'Add view mode'
weight: 1 weight: 1
class: \Drupal\field_ui\DisplayModeLocalAction
appears_on: appears_on:
- entity.entity_view_mode.collection - entity.entity_view_mode.collection
...@@ -9,6 +10,7 @@ field_ui.entity_form_mode_add: ...@@ -9,6 +10,7 @@ field_ui.entity_form_mode_add:
route_name: field_ui.entity_form_mode_add route_name: field_ui.entity_form_mode_add
title: 'Add form mode' title: 'Add form mode'
weight: 1 weight: 1
class: \Drupal\field_ui\DisplayModeLocalAction
appears_on: appears_on:
- entity.entity_form_mode.collection - entity.entity_form_mode.collection
......
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
namespace Drupal\field_ui\Controller; namespace Drupal\field_ui\Controller;
use Drupal\Component\Serialization\Json;
use Drupal\Core\Controller\ControllerBase; use Drupal\Core\Controller\ControllerBase;
use Drupal\Core\Url; use Drupal\Core\Url;
...@@ -22,14 +23,26 @@ public function viewModeTypeSelection() { ...@@ -22,14 +23,26 @@ public function viewModeTypeSelection() {
if ($entity_type->get('field_ui_base_route') && $entity_type->hasViewBuilderClass()) { if ($entity_type->get('field_ui_base_route') && $entity_type->hasViewBuilderClass()) {
$entity_types[$entity_type_id] = [ $entity_types[$entity_type_id] = [
'title' => $entity_type->getLabel(), 'title' => $entity_type->getLabel(),
'url' => Url::fromRoute('entity.entity_view_mode.add_form', ['entity_type_id' => $entity_type_id]), 'url' => Url::fromRoute('entity.entity_view_mode.add_form', ['entity_type_id' => $entity_type_id])->setOption('attributes', [
'localized_options' => [], 'class' => ['use-ajax'],
'data-dialog-type' => 'modal',
'data-dialog-options' => Json::encode([
'width' => '880',
]),
]),
]; ];
} }
} }
// Move content at the top.
array_splice($entity_types, 0, 0, array_splice($entity_types, array_search('node', array_keys($entity_types)), 1));
return [ return [
'#theme' => 'admin_block_content', '#theme' => 'admin_block_content',
'#content' => $entity_types, '#content' => $entity_types,
'#attached' => [
'library' => [
'core/drupal.dialog.ajax',
],
],
]; ];
} }
...@@ -45,14 +58,26 @@ public function formModeTypeSelection() { ...@@ -45,14 +58,26 @@ public function formModeTypeSelection() {
if ($entity_type->get('field_ui_base_route') && $entity_type->hasFormClasses()) { if ($entity_type->get('field_ui_base_route') && $entity_type->hasFormClasses()) {
$entity_types[$entity_type_id] = [ $entity_types[$entity_type_id] = [
'title' => $entity_type->getLabel(), 'title' => $entity_type->getLabel(),
'url' => Url::fromRoute('entity.entity_form_mode.add_form', ['entity_type_id' => $entity_type_id]), 'url' => Url::fromRoute('entity.entity_form_mode.add_form', ['entity_type_id' => $entity_type_id])->setOption('attributes', [
'localized_options' => [], 'class' => ['use-ajax'],
'data-dialog-type' => 'modal',
'data-dialog-options' => Json::encode([
'width' => '880',
]),
]),
]; ];
} }
} }
// Move content at the top.
array_splice($entity_types, 0, 0, array_splice($entity_types, array_search('node', array_keys($entity_types)), 1));
return [ return [
'#theme' => 'admin_block_content', '#theme' => 'admin_block_content',
'#content' => $entity_types, '#content' => $entity_types,
'#attached' => [
'library' => [
'core/drupal.dialog.ajax',
],
],
]; ];
} }
......
<?php
namespace Drupal\field_ui;
use Drupal\Component\Serialization\Json;
use Drupal\Component\Utility\NestedArray;
use Drupal\Core\Menu\LocalActionDefault;
use Drupal\Core\Routing\RouteMatchInterface;
/**
* Defines a local action plugin with modal dialog.
*/
class DisplayModeLocalAction extends LocalActionDefault {
/**
* {@inheritdoc}
*/
public function getOptions(RouteMatchInterface $route_match) {
$options = parent::getOptions($route_match);
$options = NestedArray::mergeDeepArray([[
'attributes' => [
'class' => ['button', 'use-ajax'],
'data-dialog-type' => 'modal',
'data-dialog-options' => Json::encode([
'width' => '880',
]),
],
], $options,
]);
return $options;
}
}
...@@ -2,6 +2,8 @@ ...@@ -2,6 +2,8 @@
namespace Drupal\field_ui; namespace Drupal\field_ui;
use Drupal\Component\Serialization\Json;
use Drupal\Component\Utility\NestedArray;
use Drupal\Core\Config\Entity\ConfigEntityListBuilder; use Drupal\Core\Config\Entity\ConfigEntityListBuilder;
use Drupal\Core\Entity\EntityInterface; use Drupal\Core\Entity\EntityInterface;
use Drupal\Core\Entity\EntityStorageInterface; use Drupal\Core\Entity\EntityStorageInterface;
...@@ -69,6 +71,31 @@ public function buildRow(EntityInterface $entity) { ...@@ -69,6 +71,31 @@ public function buildRow(EntityInterface $entity) {
return $row + parent::buildRow($entity); return $row + parent::buildRow($entity);
} }
/**
* {@inheritdoc}
*/
public function getOperations(EntityInterface $entity) {
// Make the edit form render in a dialog, like the add form.
// The edit form also contains an option to delete the view mode, which
// also spawns a dialog. Rather than have nested dialogs, we allow the
// existing dialog to be replaced, so users will be shown the list again
// if they cancel deleting the view mode.
$operations = parent::getOperations($entity);
if (isset($operations['edit'])) {
$operations['edit'] = NestedArray::mergeDeepArray([[
'attributes' => [
'class' => ['button', 'use-ajax'],
'data-dialog-type' => 'modal',
'data-dialog-options' => Json::encode([
'width' => '880',
]),
],
], $operations['edit'],
]);
}
return $operations;
}
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
...@@ -117,7 +144,20 @@ public function render() { ...@@ -117,7 +144,20 @@ public function render() {
'data' => [ 'data' => [
'#type' => 'link', '#type' => 'link',
'#url' => Url::fromRoute($short_type == 'view' ? 'entity.entity_view_mode.add_form' : 'entity.entity_form_mode.add_form', ['entity_type_id' => $entity_type]), '#url' => Url::fromRoute($short_type == 'view' ? 'entity.entity_view_mode.add_form' : 'entity.entity_form_mode.add_form', ['entity_type_id' => $entity_type]),
'#title' => $this->t('Add new @entity-type %label', ['@entity-type' => $this->entityTypes[$entity_type]->getLabel(), '%label' => $this->entityType->getSingularLabel()]), '#title' => $this->t('Add %label for @entity-type', ['@entity-type' => $this->entityTypes[$entity_type]->getLabel(), '%label' => $this->entityType->getSingularLabel()]),
'#button_type' => 'primary',
'#attributes' => [
'class' => ['button', 'use-ajax', 'button--small'],
'data-dialog-type' => 'modal',
'data-dialog-options' => Json::encode([
'width' => '880',
]),
],
'#attached' => [
'library' => [
'core/drupal.dialog.ajax',
],
],
], ],
'colspan' => count($table['#header']), 'colspan' => count($table['#header']),
]; ];
......
...@@ -12,19 +12,12 @@ ...@@ -12,19 +12,12 @@
*/ */
class EntityDisplayModeAddForm extends EntityDisplayModeFormBase { class EntityDisplayModeAddForm extends EntityDisplayModeFormBase {
/**
* The entity type for which the display mode is being created.
*
* @var string
*/
protected $targetEntityTypeId;
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function buildForm(array $form, FormStateInterface $form_state, $entity_type_id = NULL) { public function buildForm(array $form, FormStateInterface $form_state, $entity_type_id = NULL) {
$this->targetEntityTypeId = $entity_type_id; $form = parent::buildForm($form, $form_state, $entity_type_id);
$form = parent::buildForm($form, $form_state);
// Change replace_pattern to avoid undesired dots. // Change replace_pattern to avoid undesired dots.
$form['id']['#machine_name']['replace_pattern'] = '[^a-z0-9_]+'; $form['id']['#machine_name']['replace_pattern'] = '[^a-z0-9_]+';
$definition = $this->entityTypeManager->getDefinition($this->targetEntityTypeId); $definition = $this->entityTypeManager->getDefinition($this->targetEntityTypeId);
......
...@@ -2,8 +2,15 @@ ...@@ -2,8 +2,15 @@
namespace Drupal\field_ui\Form; namespace Drupal\field_ui\Form;
use Drupal\Core\Entity\Display\EntityFormDisplayInterface;
use Drupal\Core\Entity\Display\EntityViewDisplayInterface;
use Drupal\Core\Entity\EntityDisplayRepositoryInterface;
use Drupal\Core\Entity\EntityForm; use Drupal\Core\Entity\EntityForm;
use Drupal\Core\Entity\EntityTypeBundleInfoInterface;
use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Url;
use Drupal\field_ui\FieldUI;
use Symfony\Component\DependencyInjection\ContainerInterface;
/** /**
* Provides the generic base class for entity display mode forms. * Provides the generic base class for entity display mode forms.
...@@ -17,12 +24,58 @@ abstract class EntityDisplayModeFormBase extends EntityForm { ...@@ -17,12 +24,58 @@ abstract class EntityDisplayModeFormBase extends EntityForm {
*/ */
protected $entityType; protected $entityType;
/**
* The display context. Either 'view' or 'form'.
*
* @var string
*/
protected string $displayContext;
/**
* The entity type for which the display mode is being created or edited.
*
* @var string|null
*/
protected ?string $targetEntityTypeId;
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
protected function init(FormStateInterface $form_state) { protected function init(FormStateInterface $form_state) {
parent::init($form_state); parent::init($form_state);
$this->entityType = $this->entityTypeManager->getDefinition($this->entity->getEntityTypeId()); $this->entityType = $this->entityTypeManager->getDefinition($this->entity->getEntityTypeId());
$this->displayContext = str_replace(['entity_', '_mode'], '', $this->entityType->id());
}
/**
* Constructs a EntityDisplayModeFormBase object.
*
* @param \Drupal\Core\Entity\EntityTypeBundleInfoInterface $entityTypeBundleInfo
* The entity type bundle service.
* @param \Drupal\Core\Entity\EntityDisplayRepository $entityDisplayRepository
* The entity display repository.
*/
public function __construct(protected EntityTypeBundleInfoInterface $entityTypeBundleInfo, protected EntityDisplayRepositoryInterface $entityDisplayRepository) {}
/**
* {@inheritdoc}
*/
public static function create(ContainerInterface $container) {
return new static(
$container->get('entity_type.bundle.info'),
$container->get('entity_display.repository'),
);
}
/**
* {@inheritdoc}
*/
public function buildForm(array $form, FormStateInterface $form_state, $entity_type_id = NULL) {
if (!$entity_type_id && !$this->entity->isNew()) {
$entity_type_id = $this->entity->getTargetType();
}
$this->targetEntityTypeId = $entity_type_id;
return parent::buildForm($form, $form_state);
} }
/** /**
...@@ -47,6 +100,30 @@ public function form(array $form, FormStateInterface $form_state) { ...@@ -47,6 +100,30 @@ public function form(array $form, FormStateInterface $form_state) {
'replace_pattern' => '[^a-z0-9_.]+', 'replace_pattern' => '[^a-z0-9_.]+',
], ],
]; ];
$bundle_info_service = $this->entityTypeBundleInfo;
$bundles = $bundle_info_service->getAllBundleInfo();
$definition = $this->entityTypeManager->getDefinition($this->entity->isNew() ? $this->targetEntityTypeId : $this->entity->getTargetType());
$bundles_by_entity = [];
$defaults = [];
foreach (array_keys($bundles[$definition->id()]) as $bundle) {
$bundles_by_entity[$bundle] = $bundles[$definition->id()][$bundle]['label'];
// Determine default display modes.
if (!$this->entity->isNew()) {
[, $display_mode_name] = explode('.', $this->entity->id());
if ($this->getDisplayByContext($bundle, $display_mode_name)) {
$defaults[$bundle] = $bundle;
}
}
}
$form['bundles_by_entity'] = [
'#type' => 'checkboxes',
'#title' => $this->t('Enable this @display-mode for the following @bundle-label types:', ['@display-mode' => $this->entityType->getSingularLabel(), '@bundle-label' => $definition->getLabel()]),
'#description' => $this->t('This @display-mode will still be available for the rest of the @bundle-label types if not checked here, but it will not be enabled by default.', ['@bundle-label' => $definition->getLabel(), '@display-mode' => $this->entityType->getSingularLabel()]),
'#options' => $bundles_by_entity,
'#default_value' => $defaults,
];
return $form; return $form;
} }
...@@ -83,6 +160,132 @@ public function save(array $form, FormStateInterface $form_state) { ...@@ -83,6 +160,132 @@ public function save(array $form, FormStateInterface $form_state) {
$this->entity->save(); $this->entity->save();
\Drupal::service('entity_field.manager')->clearCachedFieldDefinitions(); \Drupal::service('entity_field.manager')->clearCachedFieldDefinitions();
$form_state->setRedirectUrl($this->entity->toUrl('collection')); $form_state->setRedirectUrl($this->entity->toUrl('collection'));
[, $display_mode_name] = explode('.', $form_state->getValue('id'));
$target_entity_id = $this->targetEntityTypeId;
foreach ($form_state->getValue('bundles_by_entity') as $bundle => $value) {
if (!empty($value)) {
// Add a new entity view/form display if it doesn't already exist.
if (!$this->getDisplayByContext($bundle, $display_mode_name)) {
$display = $this->getEntityDisplay($target_entity_id, $bundle, 'default')->createCopy($display_mode_name);
$display->save();
}
// This message is still helpful, even if the view/form display hasn't
// changed, so we keep it outside the above check.
$url = $this->getOverviewUrl($display_mode_name, $value);
$bundle_info_service = $this->entityTypeBundleInfo;
$bundles = $bundle_info_service->getAllBundleInfo();
$bundle_label = $bundles[$target_entity_id][$bundle]['label'];
$display_mode_label = $form_state->getValue('label');
$this->messenger()->addStatus($this->t('<a href=":url">Configure the %display_mode_label %mode mode for %bundle_label</a>.', ['%mode' => $this->displayContext, '%display_mode_label' => $display_mode_label, '%bundle_label' => $bundle_label, ':url' => $url->toString()]));
}
else {
// The view/form display has been unchecked, so we need to delete this.
// There's no confirmation of deleting the view/form display on the node
// content type forms either, so we match that behavior.
if ($display = $this->getDisplayByContext($bundle, $display_mode_name)) {
$display->delete();
}
}
}
}
/**
* Returns an entity display object to be used by this form.
*
* @param string $entity_type_id
* The target entity type ID of the entity display.
* @param string $bundle
* The target bundle of the entity display.
* @param string $mode
* A view or form mode.
*
* @return \Drupal\Core\Entity\Display\EntityDisplayInterface
* An entity display.
*/
private function getEntityDisplay($entity_type_id, $bundle, $mode) {
return match($this->displayContext) {
'view' => $this->entityDisplayRepository->getViewDisplay($entity_type_id, $bundle, $mode),
'form' => $this->entityDisplayRepository->getFormDisplay($entity_type_id, $bundle, $mode),
};
}
/**
* Returns the Url object for a specific entity (form) display edit form.
*
* @param string $mode
* The form or view mode.
* @param string $bundle
* The entity bundle name.
*
* @return \Drupal\Core\Url
* A Url object for the overview route.
*/
private function getOverviewUrl($mode, $bundle): Url {
$entity_type = $this->entityTypeManager->getDefinition($this->targetEntityTypeId);
return match($this->displayContext) {
'view' => Url::fromRoute('entity.entity_view_display.' . $this->targetEntityTypeId . '.view_mode', [
'view_mode_name' => $mode,
] + FieldUI::getRouteBundleParameter($entity_type, $bundle)),
'form' => Url::fromRoute('entity.entity_form_display.' . $this->targetEntityTypeId . '.form_mode', [
'form_mode_name' => $mode,
] + FieldUI::getRouteBundleParameter($entity_type, $bundle)),
};
}
/**
* Load the view display for a given bundle and view mode name.
*
* @param string $bundle
* The entity bundle to load the view display for.
* @param string $view_mode_name
* The view mode name such as "full_content" to load the view display for.
*
* @return \Drupal\Core\Entity\Display\EntityViewDisplayInterface|null
* Returns the view display, or NULL if one does not exist.
*/
private function getViewDisplay(string $bundle, string $view_mode_name): ?EntityViewDisplayInterface {
$view_mode_id = $this->targetEntityTypeId . '.' . $bundle . '.' . $view_mode_name;
return $this->entityTypeManager->getStorage('entity_view_display')->load($view_mode_id);
}
/**
* Load the form display for a given bundle and form mode name.
*
* @param string $bundle
* The entity bundle to load the form display for.
* @param string $form_mode_name
* The form mode name to load the form display for.
*
* @return \Drupal\Core\Entity\Display\EntityFormDisplayInterface|null
* Returns the form display, or NULL if one does not exist.
*/
private function getFormDisplay(string $bundle, string $form_mode_name): ?EntityFormDisplayInterface {
$form_mode_id = $this->targetEntityTypeId . '.' . $bundle . '.' . $form_mode_name;
return $this->entityTypeManager->getStorage('entity_form_display')->load($form_mode_id);
}
/**
* Returns View or Form display based on display context.
*
* @param string $bundle
* The entity bundle to load the display for.
* @param string $display_mode_name
* The display mode name to load the display for.
*
* @return \Drupal\Core\Entity\Display\EntityFormDisplayInterface|\Drupal\Core\Entity\Display\EntityViewDisplayInterface|null
* Returns the display, or NULL if one does not exist.
*/
private function getDisplayByContext(string $bundle, string $display_mode_name): EntityFormDisplayInterface|EntityViewDisplayInterface|null {
return match($this->displayContext) {
'view' => $this->getViewDisplay($bundle, $display_mode_name),
'form' => $this->getFormDisplay($bundle, $display_mode_name),
};
} }
} }
<?php
namespace Drupal\Tests\field_ui\FunctionalJavascript;
use Drupal\Core\Entity\Entity\EntityFormMode;
use Drupal\FunctionalJavascriptTests\WebDriverTestBase;
/**
* Tests the bundle selection for view & form display modes.
*
* @group field_ui
*/
class DisplayModeBundleSelectionTest extends WebDriverTestBase {
/**
* {@inheritdoc}
*/
protected static $modules = [
'node',
'field_ui',
'block',
];
/**
* {@inheritdoc}
*/
protected $defaultTheme = 'stark';
/**
* {@inheritdoc}
*/
protected function setUp(): void {
parent::setUp();
$this->drupalCreateContentType([
'name' => 'Article',
'type' => 'article',
]);
$this->drupalCreateContentType([
'name' => 'Page',
'type' => 'page',
]);
$this->drupalPlaceBlock('local_actions_block');
$user = $this->drupalCreateUser([
'administer display modes',
'administer node display',
'administer node form display',
]);
// Create a new form mode 'foobar' for content.
EntityFormMode::create([
'id' => 'node.foobar',
'targetEntityType' => 'node',
'label' => 'Foobar',
])->save();
$this->drupalLogin($user);
}
/**
* Tests the bundle selection.
*
* @param string $display_mode
* View or Form display mode.
* @param string $path
* Display mode path.
* @param string $custom_mode
* Custom mode to test.
*
* @dataProvider providerBundleSelection
*/
public function testBundleSelection($display_mode, $path, $custom_mode) {
$page = $this->getSession()->getPage();
$assert_session = $this->assertSession();
// Add new display mode for content.
$this->drupalGet("/admin/structure/display-modes/$display_mode");
$this->assertNotEmpty($assert_session->waitForText("Add $display_mode mode"));
$this->clickLink("Add $display_mode mode for Content");
$this->assertNotEmpty($assert_session->waitForText("Add new Content $display_mode mode"));
$page->find('css', '[data-drupal-selector="edit-label"]')->setValue('test');
$page->find('css', '[data-drupal-selector="edit-bundles-by-entity-article"]')->check();
$page->find('css', '.ui-dialog-buttonset')->pressButton('Save');
// Verify that test display mode is selected for article content type.
$this->drupalGet("/admin/structure/types/manage/article/$path");
$page->find('css', '[data-drupal-selector="edit-modes"]')->pressButton('Custom display settings');
$checkbox = $page->find('css', '[data-drupal-selector="edit-display-modes-custom-test"]');
$this->assertTrue($checkbox->isChecked());
// Verify that test display mode is not selected for page content type.
$this->drupalGet("/admin/structure/types/manage/page/$path");
$page->find('css', '[data-drupal-selector="edit-modes"]')->pressButton('Custom display settings');
$checkbox = $page->find('css', '[data-drupal-selector="edit-display-modes-custom-test"]');
$this->assertFalse($checkbox->isChecked());
// Click Add view/form display mode button.
$this->drupalGet("/admin/structure/display-modes/$display_mode");
$this->assertNotEmpty($assert_session->waitForText("Add $display_mode mode"));
$this->clickLink("Add $display_mode mode");
$this->assertNotEmpty($assert_session->waitForText("Choose $display_mode mode entity type"));
// Add new view/form display mode for content.
$this->clickLink('Content');
$this->assertNotEmpty($assert_session->waitForText("Add new Content $display_mode mode"));
$page->find('css', '[data-drupal-selector="edit-label"]')->setValue('test2');
$page->find('css', '[data-drupal-selector="edit-bundles-by-entity-article"]')->check();
$page->find('css', '.ui-dialog-buttonset')->pressButton('Save');
// Verify that test2 display mode is selected for article content type.
$this->drupalGet("/admin/structure/types/manage/article/$path");
$page->find('css', '[data-drupal-selector="edit-modes"]')->pressButton('Custom display settings');
$checkbox = $page->find('css', '[data-drupal-selector="edit-display-modes-custom-test2"]');
$this->assertTrue($checkbox->isChecked());
// Verify that test2 display mode is not selected for page content type.
$this->drupalGet("/admin/structure/types/manage/page/$path");
$page->find('css', '[data-drupal-selector="edit-modes"]')->pressButton('Custom display settings');
$checkbox = $page->find('css', '[data-drupal-selector="edit-display-modes-custom-test2"]');
$this->assertFalse($checkbox->isChecked());
// Verify that display mode is not selected on article content type.
$this->drupalGet("/admin/structure/types/manage/article/$path");
$page->find('css', '[data-drupal-selector="edit-modes"]')->pressButton('Custom display settings');
$checkbox = $page->find('css', "[data-drupal-selector='edit-display-modes-custom-$custom_mode']");
$this->assertFalse($checkbox->isChecked());
// Edit existing display mode and enable it for article content type.
$this->drupalGet("/admin/structure/display-modes/$display_mode");
$this->assertNotEmpty($assert_session->waitForText("Add $display_mode mode"));
$page->find('xpath', '//ul[@class = "dropbutton"]/li[1]/a')->click();
$this->assertNotEmpty($assert_session->waitForText("This $display_mode mode will still be available for the rest of the Content types if not checked here, but it will not be enabled by default."));
$page->find('css', '[data-drupal-selector="edit-bundles-by-entity-article"]')->check();
$page->find('css', '.ui-dialog-buttonset')->pressButton('Save');
// Verify that display mode is selected on article content type.
$this->drupalGet("/admin/structure/types/manage/article/$path");
$page->find('css', '[data-drupal-selector="edit-modes"]')->pressButton('Custom display settings');
$checkbox = $page->find('css', "[data-drupal-selector='edit-display-modes-custom-$custom_mode']");
$this->assertTrue($checkbox->isChecked());
}
/**
* Data provider for testBundleSelection().
*/
public function providerBundleSelection() {
return [
'view display' => ['view', 'display', 'full'],
'form display' => ['form', 'form-display', 'foobar'],
];
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment