Thursday, March 8, 2012

Saving without validation

Hello all
I am using CakePHP 1.3.
In my model validation I added wrong field which is not included in my
table. Yet the data is saved
without showing any error.
Here's my model....
class patient extends AppModel
{
var $name = 'patients';
var $hasOne = 'Doctors';
var $validate = array(
'login' => array( // The login is not a field in my table
'patients'
'rule' => array('between', 5, 15),
'message' => 'Between 5 to 15 characters'
)
);
}
Here's my controller....
<?php
class PatientsController extends AppController {
var $helpers = array('Html', 'Form');
var $name = 'patients';
var $components = array('Session');
function index() {
$this->set('patients', $this->Patient->find('all'));
}
function add() {
if (!empty($this->data)) {
pr($this->data);
if ($this->Patient->saveAll($this->data)) {
$this->Session->setFlash('Your patient has been
saved.');
$this->redirect(array('action' => 'index'));
}
}
}
}

?>

The problem is the validates function always return true (although it
contains invalid field)
What I want is, get an error message when wrong validation is added.

Thanks and Regards

--
Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org
Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate