Ini kan saya coba pakai nestedsetbehavior
Nah disitu diterangkan
$category1=new Category;
$category1->title='Ford';
$category2=new Category;
$category2->title='Mercedes';
$category3=new Category;
$category3->title='Audi';
$root=Category::model()->findByPk(1);
$category1->appendTo($root);
$category2->insertAfter($category1);
$category3->insertBefore($category1);
script itu saya taruh di actionCreate.
public function actionCreate()
{
$model=new Category;
if(isset($_POST['Category']))
{
$category1=new Category;
$category1->category_name='Motor';
$category1->category_description='MotorBocor Lho';
$root=Category::model()->findByPk(3);
$category1->appendTo($root);
}
$this->render('create',array(
'model'=>$model,
));
}
Nah, sedangkan kalau mau tambah node baru kan pakai
$category3=new Category;
$category3->title='Audi';
$root=Category::model()->findByPk(1);
$category1->appendTo($root);
$category2->insertAfter($category1);
$category3->insertBefore($category1);
kalau mau akses $_POST[‘Category’] judul, deskripsi gimana ya?
Terimakasih