<?php
class CreateAction extends BaseAction
{
    public function run()
    {
        $chapter = new Chapters();
        $chapter->bookid = Yii::app()->request->getQuery('id');
        $this->getController()->performAjaxValidation($chapter);
        
        if (isset($_POST['Chapters']) && Yii::app()->request->isAjaxRequest)
        {
            $chapter->attributes = $_POST['Chapters'];
            if ($chapter->save())
            {
                Yii::app()->end();
                //$this->getController()->redirect(array('list', 'id'=>$chapter->bookid));
            }
        }
        
        $this->getController()->renderPartial('create', array('chapter' => $chapter), false, true);
    }
}