protected function LinkClassWidgetTest::setFormDisplay in Link class 8
Same name and namespace in other branches
- 2.0.x tests/src/Functional/LinkClassWidgetTest.php \Drupal\Tests\link_class\Functional\LinkClassWidgetTest::setFormDisplay()
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 $field_name: The field name to set.
string $widget_id: The widget id to set.
array $settings: The settings of widget.
string $mode: The mode name.
1 call to LinkClassWidgetTest::setFormDisplay()
- LinkClassWidgetTest::testLinkClassWidget in tests/
src/ Functional/ LinkClassWidgetTest.php - Tests link class widget.
File
- tests/
src/ Functional/ LinkClassWidgetTest.php, line 249
Class
- LinkClassWidgetTest
- Tests link_class field widgets.
Namespace
Drupal\Tests\link_class\FunctionalCode
protected function setFormDisplay($form_display_id, $entity_type, $bundle, $field_name, $widget_id, array $settings, $mode = 'default') {
// 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();
}
}