Hi,
I'm baking project and exposing application via REST using CakePHP 2.5.x.It's fine but this moment i bake add method in User, follows the code:
public function add() {
$this->request->allowMethod('post');
$this->User->create();
if ($this->User->save($this->request->data)) {
$message = 'Saved';
} else {
$message = 'Error';
}
$this->set(array(
'message' => $message,
'_serialize' => array('message')
));
}
{
"name": "Method Not Allowed",
"message": "Method Not Allowed",
"url": "/app/users/add"
}
{
"message": "Saved"
}
* no params
{
"message": "Error"
}
* params: { data[User][first_name] : '', data[User][last_name] : '', data[User][email] : '' }
"message": "Error"
}
* params: { data[User][first_name] : '', data[User][last_name] : '', data[User][email] : '' }
In the 2 request I do not pass any argument and even then the user is saved, the validate method is despised.
I need create if for check empty ($this->request->data) or exists solution more elegant ? If yes, my application have many methods add in others controllers, don't repeat yourself, how to do ?
I need create if for check empty ($this->request->data) or exists solution more elegant ? If yes, my application have many methods add in others controllers, don't repeat yourself, how to do ?
--
Atenciosamente,
Rafael F. Queiroz
Rafael F. Queiroz
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP
---
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscribe@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.
No comments:
Post a Comment