public function afterSave(Model $Model, $created, $options = array()) { $isTree = in_array('Tree', array_map('strtolower', $Model->Behaviors->attached())); if ($Model->brwConfig['sortable'] and $created and !$isTree) { $data = $Model->data; $Model->saveField($Model->brwConfig['sortable']['field'], $Model->id); $Model->data = $data; } if ($isTree) { $Model->recover(); } }