public function edit($id)
    {
        $this->loadModel('Comment.Comments');
        $comment = $this->Comments
            ->find()
            ->contain(['Users'])
            ->where(['Comments.id' => $id, 'Comments.table_alias' => $this->_manageTable])
            ->first();

        if (!$comment) {
            throw new RecordNotFoundException(__d('comment', 'Comment could not be found.'));
        }

        if ($this->request->data()) {
            $comment->accessible('*', false);
            $comment->accessible(['subject', 'body', 'author_name', 'author_email', 'author_web', 'status'], true);
            $validator = $comment->user_id ? 'default' : 'anonymous';
            $this->Comments->patchEntity($comment, $this->request->data(), ['validate' => $validator]);
            $errors = $comment->errors();

            if (empty($errors)) {
                $this->Comments->save($comment, ['associated' => false]);
                $this->Flash->success(__d('comment', 'Comment saved!.'));
                $this->redirect($this->referer());
            } else {
                $this->Flash->danger(__d('comment', 'Comment could not be saved, please check your information.'));
            }
        }

        $this->title(__d('comment', 'Editing Comment'));
        $this->set('comment', $comment);
    }
public function edit($id)
    {
        $this->loadModel('Comment.Comments');
        $comment = $this->Comments
            ->find()
            ->contain(['Users'])
            ->where(['Comments.id' => $id, 'Comments.table_alias' => $this->_manageTable])
            ->first();

        if (!$comment) {
            throw new RecordNotFoundException(__d('comment', 'Comment could not be found.'));
        }

        if ($this->request->data()) {
            $comment->accessible('*', false);
            $comment->accessible(['subject', 'body', 'author_name', 'author_email', 'author_web', 'status'], true);
            $validator = $comment->user_id ? 'default' : 'anonymous';
            $this->Comments->patchEntity($comment, $this->request->data(), ['validate' => $validator]);
            $errors = $comment->errors();

            if (empty($errors)) {
                $this->Comments->save($comment, ['associated' => false]);
                $this->Flash->success(__d('comment', 'Comment saved!.'));
                $this->redirect($this->referer());
            } else {
                $this->Flash->danger(__d('comment', 'Comment could not be saved, please check your information.'));
            }
        }

        $this->title(__d('comment', 'Editing Comment'));
        $this->set('comment', $comment);
    }
public function edit ( $ id ) { $ this -> loadModel ( 'Comment.Comments' ) ; $ comment = $ this -> Comments -> find ( ) -> contain ( [ 'Users' ] ) -> where ( [ 'Comments.id' => $ id , 'Comments.table_alias' => $ this -> _manageTable ] ) -> first ( ) ; if ( ! $ comment ) { throw new RecordNotFoundException ( __d ( 'comment' , 'Comment could not be found.' ) ) ; } if ( $ this -> request -> data ( ) ) { $ comment -> accessible ( '*' , false ) ; $ comment -> accessible ( [ 'subject' , 'body' , 'author_name' , 'author_email' , 'author_web' , 'status' ] , true ) ; $ validator = $ comment -> user_id ? 'default' : 'anonymous' ; $ this -> Comments -> patchEntity ( $ comment , $ this -> request -> data ( ) , [ 'validate' => $ validator ] ) ; $ errors = $ comment -> errors ( ) ; if ( empty ( $ errors ) ) { $ this -> Comments -> save ( $ comment , [ 'associated' => false ] ) ; $ this -> Flash -> success ( __d ( 'comment' , 'Comment saved!.' ) ) ; $ this -> redirect ( $ this -> referer ( ) ) ; } else { $ this -> Flash -> danger ( __d ( 'comment' , 'Comment could not be saved, please check your information.' ) ) ; } } $ this -> title ( __d ( 'comment' , 'Editing Comment' ) ) ; $ this -> set ( 'comment' , $ comment ) ; }
Edit form for given comment.

@param int $id Comment id
@return void Redirects to previous page
@throws \Cake\ORM\Exception\RecordNotFoundException When comment was not found
Edit form for given comment .