Tuesday, September 27, 2011

Re: Data Not Saving Saving to db

To easily identify the error, you can echo pr($this->data) in the add action.
Could it be that the attributes should be lower case ? i.e. $this->Form->input('title');

Teddy

On Tue, Sep 27, 2011 at 4:43 AM, nobles <stillgrowing@gmail.com> wrote:
Hi,

I'm new to cake and have only have a fundamental understanding of
php.  I've been watching video and practicing here and I have a issue
I am running into.

in the code below, everything seems to excite correctly except the
function is not adding the text from my entries in the form to the
db.  it creates a new records and time stamps it fine.  But no data.
Please help.

*posts_controller.php*

function add() {
               if(!empty($this->data)) {
                       if($this->Post->save($this->data)) {
                               $this->Session->setFlash('Your post has been saved!');
                               $this->redirect(array('action'=>'index'));
                       } else {
                               $this->Session->setFlash('Your post was not saved.  Please try
again.');
                       }
               }

       }

*add.ctp*

<h2>Add A Post</h2>
<?php
echo $form->create('Post', array('action'=>'add'));
echo $form->input('Title');
echo $form->input('Body');
echo $form->end('Create A Post');
?>

Thanks in advance,

(b)

--
Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org
Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php

--
Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org
Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions.
 
 
To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php

No comments: