protected function EntityTestForm::prepareEntity in Drupal 10
Same name and namespace in other branches
- 8 core/modules/system/tests/modules/entity_test/src/EntityTestForm.php \Drupal\entity_test\EntityTestForm::prepareEntity()
- 9 core/modules/system/tests/modules/entity_test/src/EntityTestForm.php \Drupal\entity_test\EntityTestForm::prepareEntity()
Prepares the entity object before the form is built first.
Overrides ContentEntityForm::prepareEntity
File
- core/
modules/ system/ tests/ modules/ entity_test/ src/ EntityTestForm.php, line 19
Class
- EntityTestForm
- Form controller for the test entity edit forms.
Namespace
Drupal\entity_testCode
protected function prepareEntity() {
if (empty($this->entity->name->value)) {
// Assign a random name to new EntityTest entities, to avoid repetition in
// tests.
$random = new Random();
$this->entity->name->value = $random
->name();
}
}