Say I have a message table and a comment table. I want my / posts / view / page to display a form on one page to post a comment, like any regular blog. I'm not sure where I am going wrong, but this is what I tried:
class PostsController extends AppController { var $name = 'Posts'; var $uses = array('Post', 'Cmt'); function view($id = null) { ... if (!empty($this->data)) { $this->Cmt->create(); if ($this->Cmt->save($this->data)) { $this->Session->setFlash(__('The cmt has been saved', true)); } } $this->set('post', $this->Post->read(null, $id)); }
and in view
<?php echo $this->Form->create('Cmt');?> <fieldset> <?php echo $this->Form->input('name'); echo $this->Form->input('email'); echo $this->Form->input('title'); echo $this->Form->input('content'); ?> <div class="input select required"><label for="CmtStpageId">Post</label> <select id="CmtPostId" name="data[Cmt][post_id]"> <option value="1">postname</option> </select> </div> </fieldset> <?php echo $this->Form->end(__('Submit', true));?>
What is wrong here that the log entry will not be sent to the cmts table?
In addition, I have a message identifier hardcoded into this form, as you can see, because the select box does not populate the mail id for any reason. Any help with this would also be appreciated.
source share