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

Reply via email to