2017 © Pedro Peláez
 

symfony-bundle ordered-form-bundle

This bundle adds functionality for ordering form elements

image

becklyn/ordered-form-bundle

This bundle adds functionality for ordering form elements

  • Tuesday, February 20, 2018
  • by becklyn
  • Repository
  • 2 Watchers
  • 2 Stars
  • 65 Installations
  • PHP
  • 0 Dependents
  • 1 Suggesters
  • 0 Forks
  • 0 Open issues
  • 4 Versions
  • 81 % Grown

The README.md

Ordered Form Bundle

A bundle that makes form fields sortable., (*1)

Installation

composer require becklyn/ordered-form-bundle

Usage

This bundle adds a new form option called position:, (*2)

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:, (*3)

Value Description
"position" => "first" Places the element as the first element in the form.
"position" => "last" Places the element as the last element in the form.
"position" => 42 A simple sort order (the lower the number, the more at the top it is). Works with any integer.
"position" => ["before" => "otherfield"] Places the field before another one.
"position" => ["after" => "otherfield"] Places the field after another one.

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:, (*4)

  • A first field isn't guaranteed to be the first one (eg. if there are multiple first).
  • before and after 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., (*5)

The Versions

20/02 2018

dev-master

9999999-dev https://github.com/Becklyn/OrderedFormBundle

This bundle adds functionality for ordering form elements

  Sources   Download

BSD-3-Clause

The Requires

 

The Development Requires

20/02 2018
16/02 2018
15/02 2018