Hi,

This is my first post here. If this isn't an appropriate place to ask
questions, please point me in the right direction.

How do I save data into multiple models? This is my current code:

<?php
class Post extends AppModel {
        var $hasOne = array(
                'Meta' => array (
                        'className' => 'Meta',
                        'dependent' => TRUE,
                        'foreignKey' => 'id',
                ),
        );
}

<?php
class Meta extends AppModel {
        var $useTable = 'meta';
        var $belongsTo = array (
                'Post' => array (
                        'className' => 'Post',
                        'foreignKey' => 'id',
                ),
        );
}

<?php
class PostsController extends AppController {
        function add() {
                $this->checkLoggedIn();
                if (!empty($this->data)) {
                        if ($this->Post->save($this->data)) {
    /*
    *
    * I would like this code to save into meta as well
    *
    */
                                $this->flash('It worked', '/');
                        }
                }
        }

add.thtml
<?php echo $html->formTag('/posts/add')?>
<?php echo $html->input('Post/title') ?>
<?php echo $html->input('Meta/tid') ?>
<?php echo $html->submit() ?>

I hope you understand my question and thanks for your time.

Cheers,
  Johan Forngren


--~--~---------~--~----~------------~-------~--~----~
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?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to