In my cakephp project the save function is not working?
- by Faheem
My controller action is:
function add() {
if (!empty($this-data)) {
$this-Customer-create();
if ($this-Customer-save($this-data)) {
$this-Session-setFlash('A new Customer has been added');
$this-redirect(array('action'='index'));
}
else {
$this-Session-setFlash('The customer cannot be added this time. Try again later.');
$this-redirect(array('action'='index'));
}
}
}
My model is:
class Customer extends AppModel {
var $name = 'Customer';
var $validate = array(
'name' = array(
'length'= array(
'rule' = array('between', 4,50),
'message' = 'Name must be minimum 4 and maximum 50 characters long.'
),
'checkUnique'= array(
'rule' = 'isUnique',
'message' = 'This Name is already registered'
)
));
and this is my view:
create('Customer',array('action'='add'));?
input('Customer.name');
echo $form-input('Customer.balance',array('type'='hidden','default'=0));
?
end('Submit');?
every time I submit the form it splashes:
The customer cannot be added this time. Try again later.