Hey guys,
I am a newbie in cakePHP and need some help. I have the following code in the add() function of the invoices_controller:
function add() {
if (!empty($this->data)) {
$this->Invoice->create();
if ($this->Invoice->save($this->data)) {
$this->Session->setFlash(__('The Invoice has been saved', true), 'success');
$this->redirect(array('action' => 'index'));
} else {
$this->Session->setFlash(__('The Invoice could not be saved. Please, try again.', true));
}
}
}
The data is collected from the form in the add view, but I also have a field called "TransactionNum" which needs to store a random generated Number along with the id generated after adding a new record in the database. So say the add(), successfully added the following record: invoice.id = 12, I want to immediately update the TransactionNum with "random number + id" to give it a unique transaction number.
Any Ideas?