Acts As List

Acts as list

This act provides the capabilities for sorting and reordering a number of objects in list.

The class that has this specified needs to have a “position” column defined as an integer on the mapped database table.

Todo list example

class TodoList extends ActiveRecord
{
    var $has_many = array('todo_items', array('order' => "position"));
}
 
class TodoItem extends ActiveRecord
{
    var $belongs_to = 'todo_list';
    var $acts_as = array('list' => array('scope' => 'todo_list'));
}
 
$TodoList =& new TodoList();
 
$TodoList->list->moveToBottom();

Configuration options

  • column - specifies the column name to use for keeping the position integer (default: position)
  • scope - restricts what is to be considered a list.

More information

 
acts-as-list.txt · Last modified: 2008/03/13 16:43 by thijs