In Agile Toolkit each object you add is inserted as a child to some other object. They end up in $object->elements array, however there is no easy way to rearrange it.
To solve this problem we now have “Order” controller. It’s really simple to use and it will rearrange anything – form fields, columns, objects on the page and possibly even menu items.
$form->add('Order') ->move('email','before','name') ->now();
Code above will rearrange the fields. Note that you should call either now() or onHook(). onHook is useful if you anticipate more elements to arrive into the object. onHook($this->api,’post-init’);
Grid defines it’s columns in a separate array, but Order can work with any array, you should just specify it through useArray(). It will not work with Grid, because grid’s array is defined as protected. Grid defines function addOrder() which will do the array binding for you.
$g->addOrder() ->move('email','before','name') ->now();