Hello,
I am having a problem using the saveAll method. I am building a simple
message board application and when trying to use saveAll it hangs for
a few seconds and then shows a white screen with no error.
I have 2 models, ForumThread and ForumPost (ForumPost belongs to
ForumThread and ForumThread hasMany ForumPosts) and I am trying to
save the two records using saveAll.
Below is the code from my controller and view as well as the array
that is generated by the form.
View:
<div id="forums">
<div id="new_post">
<h2>Post new topic in <?=$category['ForumCategory']['name']?>
forums</h2>
<fieldset>
<legend>Write your message and submit</legend>
<?=$form->create('ForumThread', array('action' =>
'add'))?>
<?=$form->hidden('forum_category_id', array('value' =>
$category['ForumCategory']['id']))?>
<?=$form->input('title', array('class' => 'textbox'))?>
<?=$form->input('ForumPost.body')?>
<?=$form->end('Submit New Post')?>
</fieldset>
</div>
</div>
Controller:
function add() {
if (!empty($this->data)) {
$this->data['ForumPost']['member_id'] =
$this->Auth->user('id');
$this->data['ForumThread']['member_id'] =
$this->Auth->user('id');
// pr($this->data); die;
$this->ForumThread->create();
if ($this->ForumThread->saveAll($this->data)) {
$this->Session->setFlash(__('The ForumThread
has been saved',
true));
$this->redirect(array('action'=>'index'));
} else {
$this->Session->setFlash(__('The ForumThread
could not be saved.
Please, try again.', true));
}
}
}
Array:
Array
(
[__Token] => Array
(
[key] => 200541b16af308be8275485658b7b69b8041ad95
[fields] => b9a30fa56c5607cf2417083a0ad100db05d56f93
)
[ForumThread] => Array
(
[forum_category_id] => 1
[title] => Test
[member_id] => 1
)
[ForumPost] => Array
(
[body] => Test
[member_id] => 1
)
)
I am also using the Security component if that makes a difference.
Any help is greatly appreciated, Thanks.
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---