how to automatically create() a "thingy" :) in another model ?
Say you have 2 model classes, 'first' & 'second', where the first
hasmany of the second.
BUT the first has to have at least one of the second - right from the
start !
How do you implement that ?
maybe can you add that somehow using as a basis the following code -
as simple as possible! :):) ?? :
class First extends AppModel {
var $name = 'First';
var $hasmany = array('Second');
}
class second extends AppModel {
var $name = 'Second';
var $belongsto = array('First');
}
class FirstsController extends AppController {
var $name = 'Firsts';
function add() {
if (!empty($this->data)) {
if ($this->First->save($this->data)) {
$this->Session->setFlash('Your First has been saved.
and the 'first
of the second' created :) ');
$this->redirect(array('action' => 'index'));
}
}
}
class SecondController .....
naturally each where they belong.
many thx
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"CakePHP" 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?hl=en
-~----------~----~----~----~------~----~------~--~---