Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Undefined variable: captcha in my view #2

Open
ghost opened this issue Jan 6, 2013 · 0 comments
Open

Undefined variable: captcha in my view #2

ghost opened this issue Jan 6, 2013 · 0 comments

Comments

@ghost
Copy link

ghost commented Jan 6, 2013

ahoy,

i'm trying to implement your component but i've a little issue.

here's my code on CommentController.php

class CommentsController extends AppController {

public $name = 'Comments';
public $helpers = array('Html', 'Form', 'Session');
public $components = array('MathCaptcha','RequestHandler');

public function add($post_id = null) {
            $this->set('captcha', $this->MathCaptcha->getCaptcha());
    if ($this->request->is('post')) {
        $this->Comment->set(array('post_id'=>$post_id));
        $this->request->data['Comment']['ip'] = $this->RequestHandler->getClientIp();

  if ($this->MathCaptcha->validate($this->request->data['Comment']['captcha'])) {
            $this->Session->setFlash("ok.","notif");
            $this->redirect(array('controller' => 'posts', 'action' => 'view', $post_id));
        } else {
             $this->Session->setFlash("ko.","notif");
        }
    }
}

}

and my view

Form->input('captcha', array('label' => 'Calculate this: '.$captcha)); ?>

but when i refresh i've an error who say:

Notice (8): Undefined variable: captcha [APP\View\Elements\newcomment.ctp, line 13]
(my line 13 is the line before

don't know why sadly ... can you please help me?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

0 participants