How Validation works?
Hi,
I'm a newbie... just started using cake ... so far:
- Installed in Ubuntu ---> OK
- Apache/MySql/PHP ----> OK
- trying to follow a tutorial and something is wrong with validations adding records.
This is my code:
<?php
class Articles extends AppModel
{
var $name = 'Articles';
var $validate = array( 'title' => array('rule' => 'notEmpty'),
'body' => array('rule' => 'notEmpty')
);
}
?>
--- My Add ctp is
<!-- File: /app/views/articles/add.ctp -->
<h1>Add Article
<?php
echo $form->create('Article');
echo $form->input('title');
echo $form->input('body', array('rows' => '5'));
echo $form->end('Save Article');
?>
- Problem is that the validation is never executed even when my table fields are NOT NULL... any idea what the problem can be?
thank you
Miko
Asked by miko, on 10/3/10
2 Answers
the reason is that cake is creating a model on the fly because it can not find "Article", like hiromi said fix the class and also make sure the file name is singular
Answered by dogmatic69on 10/3/10
cake is all about convention over configuration.. it expects models to be singluar unless you tell it otherwise.
dogmatic69 - on 11/3/10
Rating
0
Viewed
230 times
Last Activity
on 11/3/10