Hi, try using

$this->User->save($this->data['User']).

The save function expects an array so that it can tell what db fields
it can map the values to. Passing it $this->data['User']['about_me']
will only pass the value of about me, and cake doesn't know what to
map it to.

Hope that helps.


mike wrote:
> I have a simple example below.  I just want a form that saves stuff to
> the database.  Its never getting to log "test2" I guess the data is
> not in the right format but how am I supposed to do it?  I've already
> spent a considerable amount of time debugging this and other problems,
> please help!
>
> thanks.
>
> CREATE TABLE users
> (
> id int NOT NULL AUTO_INCREMENT,
> lastName varchar(255),
> firstName varchar(255),
> picture_id int,
> about_me varchar(255),
> PRIMARY KEY (id)
> );
>
> here's the model:
> class User extends AppModel
> {
>     // Its always good practice to include this variable.
>     var $name = 'User';
>
>     // This is used for validation, see Chapter "Data Validation".
>     var $validate = array();
> }
>
> controller:
> class NewuserController extends AppController
> {
>       var $name = 'Newuser';
>       var $uses = Array('User');
>
>       function index()
>       {
>
>       }
>
>       function add() {
>               $this->log('in newuser_controller add()');
>               if(!empty($this->data)) {
>                       $this->log('test1');
>                       //If the form data can be validated and saved...
>                       if($this->User->save($this->data['User']['about_me'])) {
>                       $this->log('test2');
>                       //Set a session flash message and redirect.
>                               $this->Session->setFlash("User Saved!");
>                               $this->redirect('add');
>                       }
>               }
>       }
> }
>
>
> View:
>
> ...
> <form action="<?php echo $html->url('/newuser/add'); ?>"
> method="post">
> <? //echo $form->create('User'); ?>
>
>
> <FONT CLASS="text12">&nbsp;<BR>Describe yourself</FONT>
>
> <?php echo $html->textarea('User/about_me')?>
>
>       <?php echo $html->submit('Add'); ?><br/>
>
> <? //echo $form->end('Add User'); ?>
> </form>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
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