Hi, sorry for my late response.

I tested some ways and now i can save/edit.

  public function edit($id = null){
    if(empty($id)) $this->redirect('index');
    if(!$this->request->is('get')){
      $data = $this->request->data;
      $this->Translation->save($data['Translation']);
      $_data = array();
      foreach($data['Language'] as $key => $value){
          $_data[] = array(
              'id' => $value['LanguagesTranslation']['id'],
              'translation_id' => $id,
            'language_id' => $value['id'],
              'value' => $value['LanguagesTranslation']['value']
          );
      }
      $this->Translation->LanguagesTranslation->saveAll($_data);
      $this->redirect('index');
    }
    
    $this->Translation->id = $id;
    $r = $this->Translation->read();
    $this->request->data = $r;
    $this->loadModel('Language');
    $this->set('languages', $this->Language->find('all'));
  }

Thats ok, but i dont know how i can validate the joinTable, cause i must 
call 2 save functions.

Well ... maybe u know a better way,

On Friday, September 7, 2012 5:25:17 AM UTC+2, Mohammad Naghavi wrote:
>
> Hi Steffen,
> what is wrong with
> $this->Translation->LanguagesTranslation->save()
>
> that you need a better way?
>
>
> On Thu, Sep 6, 2012 at 3:25 PM, gloop <gl...@web.de <javascript:>> wrote:
>
>> Hello,
>>
>> is there a way to save directly to the joining table? Like the find data?
>>
>> Model Translation HABTM Translation:
>>
>>     $data = array(
>>         'Translation' => array(
>>             'key' => '213152374'
>>         ),
>>         'Language' => array(
>>             array(
>>                 'id' => '1',
>>                 'LanguagesTranslation' => array(
>>                     'value' => 'Das ist ein Test'
>>                 )
>>             ),
>>             array(
>>                 'id' => '2',
>>                 'LanguagesTranslation' => array(
>>                     'value' => 'This is a test'
>>                 )
>>             )
>>         )
>>     );
>>     $this->Translation->saveAll($data);
>>
>>
>> How i can fill the additional field?
>>
>> I know i can use $this->Translation->LanguagesTranslation->save() bu is 
>> there a better way?
>>
>> Tanks
>> Steffen
>>
>>  -- 
>> You received this message because you are subscribed to the Google Groups 
>> "CakePHP" group.
>> To post to this group, send email to cake...@googlegroups.com<javascript:>
>> .
>> To unsubscribe from this group, send email to 
>> cake-php+u...@googlegroups.com <javascript:>.
>> Visit this group at http://groups.google.com/group/cake-php?hl=en-US.
>>  
>>  
>>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com.
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php?hl=en-US.


Reply via email to