EasyAdminBundle
EasyAdminBundle copied to clipboard
[FEATURE] Allow sorting of collections
This PR enables drag'n'drop support to order collection fields. Entities that can be sorted need a property to store the order, their collection type need such a field - and you're done :)
- Add a property to the entity
This is as simple as:
/** * @ORM\Column(type="integer") */ private int $order = 0;
- Add that property to the entity type of your collection
class OrderableType extends AbstractType { public function buildForm(FormBuilderInterface $builder, array $options): void { $builder->add('order', IntegerType::class); } }
- Configure the
CollectionField
to be orderableCollectionField::new('questions') ->setEntryType(QuestionType::class) ->setFormTypeOption('by_reference', true) ->onlyOnForms() ->allowDelete() ->setSortOrderFieldName('order')
- Optionally: you can make that
order
field invisible, or readonly, if you don't want others to fiddle around with that setting
If you want to try it out, you can use https://github.com/NicoHaase/ea-reproducer-4293/tree/feature/test-branch-for-3645 as a fully configured environment for this feature
Closes #3645
FYI: I've just rebased the PR to cover the changes in the JS parts introduce in v3.3.0
@javiereguiluz after having released EA v4, I'd be happy to rebase this branch. Do you see any chance that this gets merged?
very good PR! it would be really nice if she was merged
This would be great. EA needs all the UI help it can get!
Would love to have this in EA !
It looks very nice, @javiereguiluz did you have the time to check this?
I would love this feature, currently I have to handle it by myself and it's a pain! @javiereguiluz any plans to merge it?
@javiereguiluz It would be great to merge this one, to improve CollectionField! Do you need help? Do not hesitate to ask, I could help :wink:
+1 for merging this feature