Re: Problems in saving form data to database

2011-03-10 Thread Afzalul Haque
post.php

On Thu, Mar 10, 2011 at 5:54 PM, Jeremy Burns | Class Outfit 
jeremybu...@classoutfit.com wrote:

 What is the name of your Post model file?

 Jeremy Burns
 Class Outfit

 jeremybu...@classoutfit.com
 http://www.classoutfit.com

 On 10 Mar 2011, at 12:22, goluhaque wrote:

  I know, I know, we can just do the $this-data part, but that doesn't
  work too.
 
  On Mar 10, 5:16 pm, Jeremy Burns | Class Outfit
  jeremybu...@classoutfit.com wrote:
  Yup - you can do that.
 
  Jeremy Burns
  Class Outfit
 
  jeremybu...@classoutfit.com
  (t) +44 (0) 208 123 3822
  (m) +44 (0) 7973 481949
  Skype: jeremy_burnshttp://www.classoutfit.com
 
  On 10 Mar 2011, at 12:14, rethab wrote:
 
 
 
 
 
 
 
  why not omitting the index 'Post' as well?
 
  On 10 Mrz., 07:29, Jeremy Burns | Class Outfit
  jeremybu...@classoutfit.com wrote:
  This line looks wrong:
 
  if ($this-Post-save($this-data['Post']['user_id']) == true) {
 
  Try:
 
  if ($this-Post-save($this-data['Post']) == true) {
 
  Jeremy Burns
  Class Outfit
 
  jeremybu...@classoutfit.comhttp://www.classoutfit.com
 
  On 10 Mar 2011, at 06:15, goluhaque wrote:
 
  My controller-
 
 function add() {
 if (!empty($this-data)) {
 $this-Post-create();
 $this-data['Post']['user_id'] =
 $this-Auth-user('id');
 if
 ($this-Post-save($this-data['Post']['user_id']) == true) {
 $this-Session-setFlash(__('The post user
 id has been saved', true));
 } else {
 $this-Session-setFlash(__('Post user id
 Could not be saved', true));
 }
 }
   }
  My view-
 
?php echo $this-element('action_shit'); ?
  div class=posts form
  ?php echo $this-Form-create('Post');?
 fieldset
 legend?php __('Add Post'); ?/legend
 ?php
 echo $this-Form-input('title');
 echo $this-Form-input('body');
 ?
 /fieldset
   ?php echo $this-Form-end(__('Submit', true));?
   /div
  My model-
  ?php
  class Post extends AppModel {
 var $name = 'Post';
 var $useDbConfig = 'DEFAULT';
 var $displayField = 'title';
 //The Associations below have been created with all possible keys,
 those that are not needed can be removed
 
 var $belongsTo = array(
 'User' = array(
 'className' = 'User',
 'foreignKey' = 'user_id',
 'conditions' = '',
 'fields' = '',
 'order' = ''
 )
 );
 var $validate = array(
 'post' = array(
 'rule' = array('minLenght', 1),
 'required' = true,
 'allowEmpty' = false,
 'message' = 'Question cannot be empty'
 )
 );
 var $hasMany = array(
 'Comment' = array(
 'className' = 'Comment',
 'foreignKey' = 'post_id',
 'dependent' = false,
 'conditions' = '',
 'fields' = '',
 'order' = '',
 'limit' = '',
 'offset' = '',
 'exclusive' = '',
 'finderQuery' = '',
 'counterQuery' = ''
 )
 );
 
  }
  ?
 
  The save function is returning false, even if there's no beforeSave()
 function in the AppController. The name of the database fields and the form
 fields matches, so there's no problem there. What can be the problem
 exactly?
 
  --
  Our newest site for the community: CakePHP Video Tutorialshttp://
 tv.cakephp.org
  Check out the new CakePHP Questions sitehttp://ask.cakephp.organdhelp
 others with their CakePHP related questions.
 
  To unsubscribe from this group, send email to
  cake-php+unsubscr...@googlegroups.com For more options, visit this
 group athttp://groups.google.com/group/cake-php
 
  --
  Our newest site for the community: CakePHP Video Tutorialshttp://
 tv.cakephp.org
  Check out the new CakePHP Questions sitehttp://ask.cakephp.organd help
 others with their CakePHP related questions.
 
  To unsubscribe from this group, send email to
  cake-php+unsubscr...@googlegroups.com For more options, visit this
 group athttp://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+unsubscr...@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 

Re: Problems in saving form data to database

2011-03-10 Thread Afzalul Haque
Haven't checked that one yet. Will do. Thanks.

2011/3/10 Alejandro Gómez Fernández agom...@gmail.com

 -BEGIN PGP SIGNED MESSAGE-
 Hash: SHA1


 Do you read the database log? The web server log?
 Sometimes this happend when there is a data type error in the database.
 Regards,


 Alejandro Gómez Fernández


 El 10/03/2011 09:22, goluhaque escribió:
  I know, I know, we can just do the $this-data part, but that doesn't
  work too.

 -BEGIN PGP SIGNATURE-
 Version: GnuPG v1.4.11 (MingW32)
 Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

 iQEcBAEBAgAGBQJNeMNKAAoJEHQn9CmeN9DJrLgH/1qxD06Rq/+e8oB/Iw0Fgpwg
 4weM9EXeWef0nc4zge0nAuaZYKm71YsYXLTUkXNYbc9GY3jYoytu1LWMPqb7aQZL
 8k7Xg5Ke1kdPRsOXC6W61b56c6RKf7pk/rhunIOyQEWFYRAj4agzBEYxXPhwJdsr
 pmXnokk11GKlqgsBf3ivGSoPg/J74w3ZveMLSl2V4kow/R69uu9DawgdUmbmXn98
 zq6Le6X7wPHqyPKn6Ng0JeqPbUd33g4Iq88fFxbzM7E3n4o18EOfr6f7EnGNd/ye
 YIr92TUCJrLIkormn4RbxOkXrEnAz05QVqGL0+OImAyUJx+ZjmaAgTCKMMhqtKk=
 =lSgf
 -END PGP SIGNATURE-

 --
 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+unsubscr...@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+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php