Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 14 additions & 4 deletions src/Field/Configurator/AssociationConfigurator.php
Original file line number Diff line number Diff line change
Expand Up @@ -354,10 +354,20 @@ private function configureCrudForm(FieldDto $field, EntityDto $entityDto, string
$crudPageName = Crud::PAGE_EDIT;
}

$field->setFormTypeOption(
'entityDto',
$this->createEntityDto($targetEntityFqcn, $targetCrudControllerFqcn, $targetCrudControllerAction, $targetCrudControllerPageName, $crudPageName),
);
$embeddedEntityDto = $this->createEntityDto($targetEntityFqcn, $targetCrudControllerFqcn, $targetCrudControllerAction, $targetCrudControllerPageName, $crudPageName);
$field->setFormTypeOption('entityDto', $embeddedEntityDto);

// The assets declared by the embedded controller's fields (e.g. TextEditorField,
// FileField, a nested CollectionField...) live on the embedded EntityDto, not on
// the parent AssociationField. Propagate them up so that
// AbstractCrudController::getFieldAssets(), which only walks top-level fields,
// picks them up and outputs the required CSS/JS on the form page that hosts the
// embedded CRUD form. See #6127.
$assets = $field->getAssets();
foreach ($embeddedEntityDto->getFields() ?? [] as $embeddedField) {
$assets = $assets->mergeWith($embeddedField->getAssets());
}
$field->setAssets($assets);
}

/**
Expand Down
13 changes: 13 additions & 0 deletions src/Field/Configurator/CollectionConfigurator.php
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,19 @@ private function configureEntryType(FieldDto $fieldDto, EntityDto $entityDto, Ad
$fieldDto->setFormTypeOption('entry_type', CrudFormType::class);
$fieldDto->setFormTypeOption('entry_options.entityDto', $editEntityDto);
$fieldDto->setFormTypeOption('prototype_options.entityDto', $newEntityDto);

// The assets declared by entry fields (e.g. TextEditorField, FileField, a nested
// CollectionField...) live on the entry EntityDto, not on the parent CollectionField.
// Propagate them up so that AbstractCrudController::getFieldAssets(), which only
// walks top-level fields, picks them up and outputs the required CSS/JS on the
// form page that hosts the embedded CRUD form. See #6127.
$assets = $fieldDto->getAssets();
foreach ([$editEntityDto, $newEntityDto] as $entryEntityDto) {
foreach ($entryEntityDto->getFields() ?? [] as $entryField) {
$assets = $assets->mergeWith($entryField->getAssets());
}
}
$fieldDto->setAssets($assets);
}

/**
Expand Down
Loading