2012-05-19 3 views
0

게스트 및 자산이라는 두 가지 모델이 있습니다. 자산 belongsTo 손님. 제출시 saveAll()을 사용하여 a) 게스트 테이블 항목을 만들고 b) 자산 정보를 만듭니다. 이 잘 작동하지만, 나는 나가 시려면().saveAll() 모델에 belongsTo 키를 추가하지 않음

어떤 조언을?

// Asset model belongsTo: 
    public $belongsTo = array(
    'User' => array('className' => 'User'), 
    'AssetType' => array('className' => 'AssetType'), 
    'Status' => array('className' => 'Status'), 
    'Guest' => array('className' => 'Guest') 
); 

// Controller: 
public function index() { 
     pr($this->request->data); 
     if($this->request->is("post")) { 
      if($this->Asset->saveAll($this->request->data)) { 
       $this->Session->setFlash("A new asset has been loaded"); 
      } 
     } 
     $assetTypes = $this->Asset->AssetType->find('list'); 
     $this->set("assetTypes", $assetTypes); 
    } 
+0

있다? – thecodeparadox

답변

0

을 사용할 때 자동으로 수행됩니다 인상이었다 Asset.guest_id에 Guest.id를 (추가 할 필요가 문제는

내가 hasOne의와 만 belongsTo를 설정을 한 것으로 제거. 내 자산 모델의 hasOne의와 belongsTo를 둘을 한 것으로 나타나고, 그것을 작동합니다!

이`$ this-> 요청 -> data`을 것입니다
관련 문제