Open MirkoV1987 opened 3 months ago
I've had same problem several times, since few months. It occurs when embedded forms are used, like CollectionField of sub-forms, or ArrayField. And it's not only field-collection.js
, but also other scripts, like field-text-editor.js
.
The solution that worked for me is to load needed JS asset manually at upper-level controller. For example:
SiteCrudController
:
yield AssociationField::new('settings')
->hideOnIndex()
->renderAsEmbeddedForm(SettingsCrudController::class)
->addJsFiles(Asset::fromEasyAdminAssetPackage('field-collection.js')->onlyOnForms()) # loaded manually
;
SettingsCrudController
:
public function configureFields(string $pageName): iterable
{
yield BooleanField::new('option1');
yield BooleanField::new('option2');
yield ArrayField::new('domains');
}
Using Symfony 7.0 + Easyadmin 4.10, with default configurations and AssetMapper to load assets.
Hi All,
I am having a similar situation. In my case I can add items (Image Entities) to the One to Many relation using a CollectionField field type with a sub-form, I can see the field-collection.js
file is loaded. Everything is working as expected except the delete functionality.
The delete button is not working as expected. In the UI, the javascript works by removing the element from the html form, when it is submitted though, there is no effect, the elements in the collection are not deleted, no query on the backend, no interaction from browser to backend either. Seems that the edit functionality in controller do not recognizes the removed entities from collection.
Versions:
My configuration of the field looks like:
CollectionField::new('images')
->setEntryType(ImageType::class)
->setFormTypeOption('by_reference', false)
->renderExpanded()
->onlyOnForms()
The configuration of the ImageType is like:
public function buildForm(FormBuilderInterface $builder, array $options): void
{
$builder
->add('title')
->add('description')
->add('sortOrder')
->add('imageFile', VichImageType::class);
}
More details:
UPDATE tb_image SET image_name = null
, which allows me to change the image used for that entitiy.Any suggestion where to look will be welcomed.
I'm noticing a similar issue as the one described by the OP, with the difference that for me field-collection.js is present in ea-edit pages but not in ea-new pages, so I can add/remove items if editing an entity but not if I'm creating a new one.
Describe the bug I want to update an item in EasyAdmin 4. When i want to add another item to a collection from an ea-edit page, add item button and remove button (the rubbish icon) do not work. Impossible to add another field to collection. Browser console is empty, no error is displayed.
To Reproduce
Example:
(OPTIONAL) Additional context