2014-04-03 84 views
1

以下this link我在創建一個註冊表單並將表格連接到表格「user」和「profile」。在yii中創建嵌套表格

public function actionRegistration() 
{ 
    $form = new CForm('application.views.user.registerForm'); 
    $form['user']->model = new Users; 
    $form['profile']->model = new Profile; 
    if($form->submitted('register') && $form->validate()) 
    { 
     $user = $form['user']->model; 
     $profile = $form['profile']->model; 
     if($user->save(false)) 
     { 
      $profile->userID = $user->id; 
      $profile->save(false); 
      $this->redirect(array('/user/login')); 
     } 
    } 

    var_dump($form->submitted('register')); 


    $this->render('registration', array('form'=>$form)); 
} 

我居然不知道什麼是$形式 - >提交(「註冊」),以及爲什麼它返回false:在我控制我如下複製了相同的代碼!

任何人都可以解釋我是什麼,什麼是傳遞給提交函數的「註冊」值!?另外爲什麼它應該在發佈表單時返回false?

+1

http://www.yiiframework.com/doc/api/1.1/CForm#submitted-細節 –

+0

你也應該提供一個模型到CForm構造函數 $ form = new CForm('application.views.user.registerForm',!!!); –

回答