cakePHP: form success message
I am using cakes form helper to create a form and then the save() function to save the data. I have some validation in my model and so if there is a validation error cake will output a message to the user which is brilliant. But if the form submit is successful and the data is saved nothing happens, the form input elements even still have the entered data in them. Is there a way to make a message appear if the save is successful and to reset 开发者_运维知识库the form so it is blank again?
Its ok I've cracked it! if the save() function is successful it returns true so you just create a condition that does whatever you want if save() if true :-)
The form prefilling is done through $this->data, so if you would reassign an empty array to it, your prefilling should be cleared as well. So ...
if ($this->User->save($this->data)) {$this->data = array();}
精彩评论