When using $model->attributes -> 2 inserted rows

Hi!

I have this code:




$this->performAjaxValidation('test', 'test-form');

$model = new test;

  if(isset($_POST['test'])) {

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

     $model->validate();

     if(!$model->hasErrors()) {

          $model->save();

    }

  }	



It works ver well, but it will always insert 2 ident rows with the correct CActiveForm data.

Why?

thx

why are you calling


$model->validate();

     if(!$model->hasErrors()) {



you don’t need to validate and check if no errors. you just need to call $model->save() and it will do both for you. Try it that way