Can I use Cakephp validation without formhelper?
for example, I was created model, controller, and view like this
model:
class KnowledgeBase extends AppModel {
public $useTable = 'corp_kb';
public $validate = array(
'kb_title' => array(
'rule' => array('minLength', '2'),
'required' => true,
'message' => 'min 2 char'
),
);
}
controller:
class KnowledgeBaseController extends AppController
{
var $name = 'KnowledgeBase';
var $ext = '.php';
public $helpers = array ('Html', 'Form', 'Js');
function kb_fill()
{
$this->layout = 'ajax';
}
function kb_input()
{
$this->autoRender = false;
$this->KnowledgeBase->set($this->data);
if(!empty($this->data))
{
if($this->KnowledgeBase->validates())
{
debug($this->data);
}
else
{
}
}
else
{
echo "data empty";
}
}
view "kb_fill":
<form id="kb_frm" method="get" action="" >
<input type="text" name="data[Knowledgebase][kb_title]"/>
<button id="postbutton">Post !</button>
</form>
for some reason I used ajax to load post into kb_input via button id, and cannot use usual method. the cakephp validation not working, or not showing the message error how can I use it without formhelper?