Hi all,
I’m trying to define the following action “validate” for the controller “ProjectsController” but for some reason cake is throwing a wobbly.
[code=php]
class ProjectsController extends AppController {
var $name = “Projects”;
//… some other actions which all work
function validate($what) {
$this->layout = “ajax”;
switch($what) {
case “title”:
$count = $this->Project->find(“count”, array(“conditions”=>array(“title”=>$this->data[“data”])));
$this->set(“isValid”, ( ($count == 0) ? true : false ));
$this->set(“message”, ( ($count == 0) ? “” : “A project with this title already exists.” ));
break;
default:
$this->set(“isValid”, false);
$this->set(“message”, “No validation rules exist for $what.”);
}
}
}
Even if I make the action completely empty:
[code=php]
function validate() {
}
Cake is still giving me:
[code=html]
Missing Method in ProjectsController
Error: The action validate is not defined in controller ProjectsController
Error: Create ProjectsController::validate() in file: app/controllers/projects_controller.php.
<?php
class ProjectsController extends AppController {
var $name = ‘Projects’;
function validate() {
}
}
?>
Does anyone have any idea why this is?