actionCreate does not work

Hi, i am very new with Yii.

I have encountered a problem maybe it is so easy, however i cannot handle despite all my efforts.

It is:

I have a table named ‘kitap’ in database, I create model/view and controller classes for the table with gii tool.

My web application render site/index as default, here is my actionIndex function in siteController.php:

public function actionIndex()


{


	// renders the view file 'protected/views/site/index.php'


	// using the default layout 'protected/views/layouts/main.php'


	$model = new Kitap;


	$this->render('index',array('model'=>$model));	}

and i have the code block

<p> <?php echo $this->renderPartial(’/kitap/_form’,array(‘model’=>$model)); ?> </p>

in site/index.php. So far, it generates a form with the inputs for ‘kitap’ fields, but when I click the submit button, It does not affect anything…

Please help me…

you should read the documentation better


$model->attributes=$_POST['Kitap'];

if($model->save()){

   $this->redirect(array('view','id'=>$model->id));

}

I have read it many times, I just couldn’t get the point.

I understand

I forgot to say, welcome to the forum

Thank you.

It just should be




$model=new Kitap;


if(isset($_POST['Kitap']))

{

	$model->attributes=$_POST['Kitap'];

	if($model->save())

		$this->redirect(array('index'));

	}


$this->render('index',array('model'=>$model));



You should not advice me that reading documentation better. I wasted many times to read documentation again and again, however I did not find the solution there. I solved it on my own.

just DO NOT direct people in a wrong way, please!!!!!

Hi Paragomi

I’m sorry about the confusion

When I said documentation, I didn’t mean only the definitive guide, there are many types of documentation, including wikis, screencasts, the blog tutorial, and also you can check the code generated by Gii, etc

Anyway, I’m happy you solved your problem

If you have more doubts, feel free to ask

Cheers,

Gustavo