Validating Of Ideas

Hi.

I have a tables named as ideyalar and persons.

In the registration page users can not create their profile if the username taken before.

And every user can create their ideas. But there I to face the problem that; users CAN CREATE the ideas with the same name.

I want to restrict this. But I don’t know how…

If you help me, I’ll be glad.

Thanks. Best regards.

P.S: IdeyalarController code:


public function actionCreate()

{

	$model = new Ideyalar;


	// Uncomment the following line if AJAX validation is needed

	// $this->performAjaxValidation($model);


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

	{

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

		$model->istifade = "1";

		$model->idcontact = Yii::app()->user->getId();


		if($model->save()){

			if($model->validate()) {

				$command = Yii::app()->db->createCommand();

				$command->insert ('mqrup', array(

					'idperson'=> Yii::app()->user->getId(),

					'idideya'=>$model->idideya));

					

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

			}

		}

	}


	$this->render('create',array(

		'model'=>$model,

	));

}

Use unique validator in your ideas model: http://www.yiiframework.com/wiki/56/#hh21