Checked those out will continue to reference them thanks:)

Here is the issue..  When I go to the blog post select a blog post and
go to its view I see the comment box and I can input information into
it.  It does pass the post_id to the database.  The problem is it
doesn't seem to display them in the view??  So I think somethings are
wonky in the view logic and control logic.  It submits the information
never sends the flash and when I use debug on the page above the logic
as show below it shows nothing..??
//---------------------------Post View--------------------------
<h1><?php echo $post['Post']['title']?></h1>

<p><small>Created: <?php echo $post['Post']['created']?></small></p>

<p><?php echo $post['Post']['body']?></p>
<?php
debug($this->data);
if (isset($data['Comment']))
{
    foreach ($data['Comment'] as $Comment)
    {
    echo "<div class=\"commentbody\">";
    echo $comment['body'];
    echo "</div>";
    echo "<div class=\"commenttitle\">";
    echo "written by ".$comment['user_id']."
         ".$time->timeAgoInWords($comment['created']);
    echo "</div>";
    }
}

else
{
    echo "No comments yet.";
}

?>
</div>
<div id="addcomment">
<?php
echo $html->formTag("/Comments/add");
echo
$html->hidden('Comment/post_id', array('value' => $post['Post']
['id']));
echo $html->textarea("Comment/body", Array("cols"=>60,"rows"=>5));
echo "<br>";
echo $html->submit("Add Comment");
?>
</form>
</div>

Comment Controller-----------

<?php
class CommentsController extends AppController {
        var $name = 'Comments';
        var $layout = 'comments';
        var $uses = array('Comment');
    function add()
    {
        if (empty($this->params['data']))
        {
            $this->Session->setFlash ("No direct access ;o)");
        }
        else
        {
            if ($this->Comment->save($this->params['data']))
            {
                $this->Session->setFlash ("Comment added");
            }
            else
            {
                $this->Session->setFlash ("Error adding comment");
            }
        }
        $Url = $this->referer("/");
        $this->redirect ($Url);
    }
}
?>


------------------------Post Controller-----------------------------


<?php


class PostsController extends AppController
{

    var $name = 'Posts';
    var $layout = 'Blog-Posts';

function index()
{
         $this->set('posts', $this->Post->findAll());
}

function view($url)
{
    $post = $this->Post->findByUrl($url);
        $this->set('post', $post);
}

    function admin_add()
    {
        if (!empty($this->data))
        {
            if ($this->Post->save($this->data))
            {
                $this->flash('Your post has been saved.','/posts');
            }
        }
    }

        function admin_delete($id)
        {
    $this->Post->del($id);
    $this->flash('The post with id: '.$id.' has been deleted.', '/
posts');
        }

        function admin_edit($id = null)
        {
        if (empty($this->data))
        {
                 $this->Post->id = $id;
                 $this->data = $this->Post->read();
        }
                else
        {
                if ($this->Post->save($this->data['Post']))
                {
            $this->flash('Your post has been updated.','/posts');
                }
        }
        }
}

?>
------------------------Post Model-----------------------------

<?php
class Post extends AppModel
{
        var $name = 'Post';

        var $validate = array(
                'title'  => VALID_NOT_EMPTY,
                'body'   => VALID_NOT_EMPTY
        );

        function beforeSave()
        {
                if (empty($this->id))
                {
                        $this->data[$this->name]['url'] = 
$this->getUniqueUrl($this-
>data[$this->name]['title'], 'url');
                }

                return true;
        }
                var $hasMany = array(
                        'Comment' =>
                                array('className' => 'Comment',
                                                'foreignKey' => 'post_id',
                                                'dependent' => true
                                ),
        );
}
?>


On Oct 9, 8:02 pm, McFadly <[EMAIL PROTECTED]> wrote:
> Looks like you need to use $form->create(), and then $form->input();
> in your post view.
>
> Try baking your views with the console application 'cake bake' (check
> out the screencasts on this subject:http://cakephp.org/screencasts)
> to see how they get baked by default, its a great way to learn.  As
> well here are links to the manual and api:
>
> http://api.cakephp.org/http://manual.cakephp.org/
>
> I've been using cake for 6 months now and still refer to them
> constantly.
>
> Also, it always helps to ask a question, rather that just posting all
> of your code.  Probably why didn't get a response right away.  Hope
> that helps.


--~--~---------~--~----~------------~-------~--~----~
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