becklyn / ordered-form-bundle
This bundle adds functionality for ordering form elements
Installs: 27 453
Dependents: 2
Suggesters: 1
Security: 0
Stars: 5
Watchers: 2
Forks: 1
Open Issues: 0
Type:symfony-bundle
Requires
- php: >=7.4
- symfony/config: ^5.4.3 || ^6.0.3 || ^7.0
- symfony/dependency-injection: ^5.4.3 || ^6.0.3 || ^7.0
- symfony/form: ^5.4.3 || ^6.0.3 || ^7.0
- symfony/http-kernel: ^5.4.4 || ^6.0.4 || ^7.0
Requires (Dev)
- roave/security-advisories: dev-master
- symfony/phpunit-bridge: ^5.4.3 || ^6.0.3 || ^7.0
README
A bundle that makes form fields sortable.
Installation
composer require becklyn/ordered-form-bundle
Usage
This bundle adds a new form option called position
:
use Symfony\Component\Form\AbstractType; use Symfony\Component\Form\FormBuilderInterface; class SomeForm extends AbstractType { /** * @inheritDoc */ public function buildForm (FormBuilderInterface $builder, array $options) : void { $builder ->add("field", null, [ "position" => /* some value */ ]); } }
The supported values are:
Caveats
This bundle focuses on speed, so the sorting is not perfect. As it is pretty easy to create a conflicting, this bundle tries a best-effort sorting, but this implies:
- A
first
field isn't guaranteed to be the first one (eg. if there are multiplefirst
). before
andafter
only guarantee the relative order, not how big the distance is between these fields (it tries to place them immediately next to each other).
If the configuration of the form is sensible and conflict-free, then the order will work as expected.