Have tried many different wayes, but with no success. I can't think out
how to populate a join table which has more than two fields.
In the index controller I 'm using the following:
$this->set('langs', $this->Lang->findAll());
In the form:
.. input fields for the seasons table ...
$html->input('Season/Year');
.....
... input fields for the seasons_langs table ....
<?php foreach ($langs as $lang): ?>
Name:
<input type="text"
name="langData[<?= $lang['Lang']['lang_id'] ?>][SeasonLang][info]" />
<?php endforeach; ?>
So, in the controller I get an array:
$this->params['form']['langData'][1][SeasonLang][Info]
and
$this->params['form']['langData'][2][SeasonLang][Info]
(suppose we have two languages)
Then I make a record for the season :
$this->Season->save($countries_data)
and then I build the arrays for the seasons_langs:
$seasons_langs_data['SeasonLang']['season_id'] =
$this->Season->getLastInsertID();
foreach ($this->params['form']['langData'] as $key => $value) {
$countries_langs_data['SeasonLang']['lang_id'] = $key;
$countries_langs_data['SeasonLang']['name'] =
$value['SeasonLang']['info'];
$this->Season->SeasonLang->save($seasons_langs_data);
}
Then in the seasons_langs table I have only one record. Cakephp saves
the record for the first language in the first iteration and then just
updates this record on the second iteration.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake
PHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/cake-php
-~----------~----~----~----~------~----~------~--~---