PHPackages                             idct/symfony-form-soft-delete-aware-entity-type-ux-autocomplete - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Database &amp; ORM](/categories/database)
4. /
5. idct/symfony-form-soft-delete-aware-entity-type-ux-autocomplete

ActiveLibrary[Database &amp; ORM](/categories/database)

idct/symfony-form-soft-delete-aware-entity-type-ux-autocomplete
===============================================================

symfony/ux-autocomplete addon to the SoftDeleteAwareEntityType which adds support for Soft Delete filter behavior to Symfony's EntityType.

1.0.0(1y ago)0112MITPHP

Since Jul 16Pushed 1y ago1 watchersCompare

[ Source](https://github.com/ideaconnect/symfony-form-soft-delete-aware-entity-type-ux-autocomplete)[ Packagist](https://packagist.org/packages/idct/symfony-form-soft-delete-aware-entity-type-ux-autocomplete)[ RSS](/packages/idct-symfony-form-soft-delete-aware-entity-type-ux-autocomplete/feed)WikiDiscussions main Synced 3w ago

READMEChangelogDependencies (5)Versions (2)Used By (0)

Symfony Form SoftDeleteAware EntityType UX Autocomplete
=======================================================

[](#symfony-form-softdeleteaware-entitytype-ux-autocomplete)

[![Tests status](https://github.com/ideaconnect/symfony-form-soft-delete-aware-entity-type-ux-autocomplete/actions/workflows/run-tests.yml/badge.svg "Tests status")](https://github.com/ideaconnect/symfony-form-soft-delete-aware-entity-type-ux-autocomplete/actions/workflows/run-tests.yml/badge.svg)[![Coverage Status](https://camo.githubusercontent.com/94247e3a8dbac4c041b1ea94ede39cc95ec04ccf177a7221e0dfbb3b9dff2169/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f6769746875622f69646561636f6e6e6563742f73796d666f6e792d666f726d2d736f66742d64656c6574652d61776172652d656e746974792d747970652d75782d6175746f636f6d706c6574652f62616467652e7376673f6272616e63683d6d61696e)](https://coveralls.io/github/ideaconnect/symfony-form-soft-delete-aware-entity-type-ux-autocomplete?branch=main)

The missing link between `softdeleteable` from [doctrine/extensions](https://github.com/doctrine-extensions/DoctrineExtensions), Symfony Form component and Symfony UX Autocomplete.

Warning!
========

[](#warning)

If you need to use this it most likely means that you have a bad architecture of your software. If you allow deletion or soft deletion you should first make sure that each related entity is updated first with `null` or new relation. This form type is meant to be used for transition purposes in systems which need to quickly add soft deletion on some entities which are used in relations, but due to time or other resources it is impossible to upgrade the actual processes.

Purpose
-------

[](#purpose)

If you are using the `softdeleteable` filter and `EntityType` forms you may encounter a situation when your CRUD Edit form in which the related entity is no longer available as soft removed. This form type will make the form still properly render, but forcing the user to update the relation using the form.

In such situation, using standard entity type you may see a screen like this:

[![Entity of type 'App\Entity\DeletableEntity' for IDs id(1) was not found](.github/images/1.png "Error message")](.github/images/1.png)

If you install package [idct/symfony-form-soft-delete-aware-entity-type](https://github.com/ideaconnect/symfony-form-soft-delete-aware-entity-type) and use the `SoftDeleteAwareEntityType` it will revert to the placeholder forcing user to update:

[![Success with the plugin](.github/images/2.png "Success")](.github/images/2.png)

This package, extension, add support for handling the same way soft deleted entities with `symfony/ux-autocomplete`:

[![Success with the plugin](.github/images/3.png "Autocomplete")](.github/images/3.png)

Compatibility
-------------

[](#compatibility)

- Symfony 6 or 7.
- Sonata Admin 3+

Installation
------------

[](#installation)

First require it in your project:

```
composer require idct/symfony-form-soft-delete-aware-entity-type-ux-type
```

NOTE: you need to also configure `idct/symfony-form-soft-delete-aware-entity-type`.

As this is not a bundle register in your `services` (for example `services.yaml`) file:

If you have autowiring:

```
    IDCT\SymfonyFormSoftDeleteAwareEntityType\SoftDeleteAwareEntityType: ~
    IDCT\SymfonyFormSoftDeleteAwareEntityType\Ux\BaseSoftDeleteEntityAutocompleteType: ~
```

If you do not use autowiring you need to pass doctrine as the first argument:

```
    IDCT\SymfonyFormSoftDeleteAwareEntityType\SoftDeleteAwareEntityType:
        arguments:
            - '@doctrine'

    IDCT\SymfonyFormSoftDeleteAwareEntityType\Ux\BaseSoftDeleteEntityAutocompleteType: ~
        arguments:
            - '@doctrine'
```

Now create your autocomplete Form Type class, same as with UX Autocomplete, but use the parent coming out of this package:

```
