コード例 #1
0
 public function test1()
 {
     $c1 = new Class1(array("attr11" => "un texto libre", "attr12" => date("Y-m-d"), "attr13" => 12345, "class2" => new Class2(array("attr21" => "otro texto libre", "attr22" => date("Y-m-d"), "attr23" => 34363, "class3" => new Class3(array("attr31" => "un ultimo texto libre", "attr32" => date("Y-m-d"), "attr33" => 83715))))));
     // class1
     // Debe fallar el save porque hay datos erroneos
     $this->assert($c1->save(), 'Test guardar class1' . print_r($c1->getErrors(), true));
 }
コード例 #2
0
 /**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  */
 public function actionCreate()
 {
     $model = new Class1();
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     if (isset($_POST['Class1'])) {
         $model->attributes = $_POST['Class1'];
         if ($model->save()) {
             $this->redirect(array('view', 'id' => $model->idclass));
         }
     }
     $this->render('create', array('model' => $model));
 }