2012-05-15 4 views
1

나는 hasmany saveall()을 시도하고 있지만 작동하지 않습니다. 내가 저장하려고하면Cakephp HasMany + SaveAll doesnt work

가 나는 모델 Carmodel hasMany의 CarmodelsImage 을 통과 배열은 다음과 같습니다 컨트롤러에서

[CarmodelsImage] => Array 
    (
     [0] => Array 
      (
       [name] => teste 
       [carmodel_id] => 1 
      ) 
    ) 

내가이 $ this-> Carmodel-> 시려면 ($ this-> 요청 - > 데이터)하지만 작동하지 않습니다.

도움이 필요합니다.

나는이 질문이 이미 게시 된 것을 알고 있지만 모든 대답을 읽고 작동하지 않습니다.

Array 
(
    [Carmodel] => Array 
       (
         //Carmodel fields here 
       ) 
    [CarmodelsImage] => Array 
         (
         [0] => Array 
          (
           [name] => teste 
           [carmodel_id] => 1 
          ) 

         [1] => Array 
          (
           [name] => abc 
           [carmodel_id] => 2 
          ) 
         .......... 
        ) 
) 

$this->Carmodel->saveAll($this->request->data, array('deep' => true)); 

당신은 관련 모델의 세부 사항을 저장하는 동안 'deep' => true 시려면와 옵션() 메소드를 사용해야합니다 :

감사

+0

서식을 정리할 수 있습니까? 정확히 어떻게됩니까? 오류가 발생 했습니까? false를 반환합니까? $ this-> request-> data의 전체 내용은 무엇입니까? – tigrang

답변

4

귀하의 요청 데이터는 다음 코드에서와 같은 배열 할 필요가있다.

관련 문제