Ordering elements

Thursday, April 22nd, 2010|Beginner tips, Version 3|by Romans

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.


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.




Posted April 23, 20107:46 am

why there are two ways of enabling this?

add(‘Order’) vs addOrder..

and, move() works explicitly with “elements” array, right?

Posted April 26, 20102:44 pm

add(‘Order’) works with ANY object and will work with children. Columns are not exactly children in a grid. They are stored in protected array. External class can’t get access. Hence the addOrder – i guess it should be called addColumnOrder().

Svetlozar Kondakov
Posted April 27, 20103:46 pm

This seems useful .. although I never had the need to use it in the past.