You are here

protected function PbfBaseTest::setFormDisplay in Permissions by field 8

Set the widget for a component in a form display.

Parameters

string $form_display_id: The form display id.

string $entity_type: The entity type name.

string $bundle: The bundle name.

string $mode: The mode name.

string $field_name: The field name to set.

string $widget_id: The widget id to set.

array $settings: The settings of widget.

6 calls to PbfBaseTest::setFormDisplay()
PbfAccessWithFormWidgetValueTest::testPbfAccessWithFormWidget in tests/src/Functional/PbfAccessWithFormWidgetValueTest.php
Test the pbf node access with a Pbf field with grants value from widget.
PbfBaseTest::attachPbfNodeFields in tests/src/Functional/PbfBaseTest.php
Helper function to create and attach a Pbf Node field.
PbfBaseTest::attachPbfRoleFields in tests/src/Functional/PbfBaseTest.php
Helper function to create and attach a Pbf Role field.
PbfBaseTest::attachPbfSynchronizedFields in tests/src/Functional/PbfBaseTest.php
Helper function to create and attach a Pbf Node field synchronized.
PbfBaseTest::attachPbfTermFields in tests/src/Functional/PbfBaseTest.php
Attach Pbf fields which reference taxonomy terms.

... See full list

File

tests/src/Functional/PbfBaseTest.php, line 334

Class

PbfBaseTest
General setup and helper function for testing pbf module.

Namespace

Drupal\Tests\pbf\Functional

Code

protected function setFormDisplay($form_display_id, $entity_type, $bundle, $mode = 'default', $field_name, $widget_id, $settings) {

  // Set article's form display.
  $this->formDisplay = EntityFormDisplay::load($form_display_id);
  if (!$this->formDisplay) {
    EntityFormDisplay::create([
      'targetEntityType' => $entity_type,
      'bundle' => $bundle,
      'mode' => $mode,
      'status' => TRUE,
    ])
      ->save();
    $this->formDisplay = EntityFormDisplay::load($form_display_id);
  }
  if ($this->formDisplay instanceof EntityFormDisplayInterface) {
    $this->formDisplay
      ->setComponent($field_name, [
      'type' => $widget_id,
      'settings' => $settings,
    ])
      ->save();
  }
}