sonata-project/SonataAdminBundle — pull request #1275 by stevelacey (2013-04-05 11:13:29+00:00)
Title: Added move method to FormMapper.

At the moment, in order to reorder fields, you have to pull out of a list of all fields, reorder them manually, and pass them back to the reorder method.

This is less than convenient, so I wrote a basic move method that handles all of that for you.

The method supports moving fields to the first or last position, as well as before and after other fields. This is especially useful when extending other admins, and thus you can't simply specify the fields in the correct order in the first place.

Example usage:

$formMapper
->add('amount')
->add('unit')
->add('name')

->move('amount', 'after', 'name')
->move('unit', 'after', 'amount')

->move('title', 'before', 'name')

->move('and_another', 'last')
->move('another_example', 'first')
;