problem: update goes through, and $validate returns true even if the
field value sent goes against the rules set in the model.
what might be causing this?
==== controller function update() in example.php ======
function update() {
$this->loadModel('modelName');
$this->modelName->set($_POST['field_name'], $_POST['field_value']);
$validates = $this->modelName->validates();
if ($validates) {
$update = $this->modelName->updateAll(
array(
$_POST['field_anme']=> '"' . $_POST
['field_value']. '"'
)
);
$result['errors'] = $validates;
} else {
$result['errors'] = $this->modelName->validationErrors;
}
}
====== model code portion =======
class modelName extends AppModel {
var $name = 'modelName ';
var $validate = array(
'field_name' => array(
'notEmpty' => array(
'rule' => 'notEmpty',
'message' => 'Can't be empty, yo.'
))
);
}
======= jquery portion ==============
$.ajax({
type: "post",
url: "/example/update",
data: 'field_value='+ field_value + '&field_name="'+ field_name,
dataType: 'json',
success: function(response){
alert(response.errors);
},
error: function(){
alert(response.errors);
}
});
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"CakePHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---