SortableModel is a helper for managing manually created order of models to Yii web framework.
- Copy/Clone dir in protected/extensions/SortableModel:
git clone https://github.com/wapmorgan/SortableModel.git protected/extensions/SortableModel
- Open your model and add behavior in
behaviors()
method like this:
public function behaviors() {
return array(
'SortableModel' => array('class' => 'ext.SortableModel.SortableModelBehavior'),
);
}
-
All newly created models will be at the end of list.
-
To move them, call
moveUp()
ormoveDown()
. -
If you delete a record, all the subsequent records are moved up one position.