The bundle is used to sort the FormView
objects in the CollectionType
.
Sorting is based on the value of the specified property.
The property is determined by the property path in the format of the Symfony PropertyAccess component.
$ composer require fsv/sortable-collection-type-bundle
// app/AppKernel.php
public function registerBundles()
{
$bundles = array(
// ...
new Fsv\SortableCollectionTypeBundle\FsvSortableCollectionTypeBundle(),
);
}
The bundle does not have any configurable parameters.
// AppBundle\Form\Type\ExampleFormType.php
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder->add('collection', CollectionType::class, [
// ...
'sort_by' => [
'property' => 'asc'
]
]);
// ...
}